static PyObject* do_chip_sets(ChipName *self, PyObject *args) { (void)args; int status = sensors_do_chip_sets(&self->chip_name); if (status < 0) { PyErr_SetString(SensorsException, sensors_strerror(status)); return NULL; } Py_RETURN_NONE; }
static int setChip(const sensors_chip_name *chip) { int ret = 0; if ((ret = idChip(chip))) { sensorLog(LOG_ERR, "Error identifying chip: %s", chip->prefix); } else if ((ret = sensors_do_chip_sets(chip))) { sensorLog(LOG_ERR, "Error performing chip sets: %s: %s", chip->prefix, sensors_strerror(ret)); ret = 50; } else { sensorLog(LOG_INFO, "Set."); } return ret; }
/* returns 1 on error */ static int do_a_set(const sensors_chip_name *name) { int err; if ((err = sensors_do_chip_sets(name))) { if (err == -SENSORS_ERR_KERNEL) { fprintf(stderr, "%s: %s\n", sprintf_chip_name(name), sensors_strerror(err)); fprintf(stderr, "Run as root?\n"); return 1; } else if (err == -SENSORS_ERR_ACCESS_W) { fprintf(stderr, "%s: At least one \"set\" statement failed\n", sprintf_chip_name(name)); } else { fprintf(stderr, "%s: %s\n", sprintf_chip_name(name), sensors_strerror(err)); } } return 0; }