diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2018-06-26 15:35:46 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2018-06-26 15:35:46 +0200 |
commit | 93b1da90ee48630d57102faa989941ce46636644 (patch) | |
tree | 3c05ff15d80348b07207fd65c3e22e70431a73a9 /psutil/_psutil_osx.c | |
parent | ca202d8edce5f3744512bfa57708c8afd142dfe4 (diff) | |
download | psutil-93b1da90ee48630d57102faa989941ce46636644.tar.gz |
#1284: give credits to @amanusk + some minor adjustments
Diffstat (limited to 'psutil/_psutil_osx.c')
-rw-r--r-- | psutil/_psutil_osx.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index 584df3b8..15f4d4f6 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -930,33 +930,27 @@ psutil_sensors_fans(PyObject *self, PyObject *args) { return NULL; fan_count = SMCGetFanNumber(SMC_KEY_FAN_NUM); - if (fan_count < 0) { + if (fan_count < 0) fan_count = 0; - } - for (key =0; key < fan_count; key++) { + + for (key = 0; key < fan_count; key++) { sprintf(fan, "Fan %d", key); speed = SMCGetFanSpeed(key); - if (speed < 0) { + if (speed < 0) continue; - } - py_tuple = Py_BuildValue( - "(si)", - fan, // label - speed // value - ); + py_tuple = Py_BuildValue("(si)", fan, speed); if (!py_tuple) goto error; - - if (PyList_Append(py_retlist, py_tuple)) { + if (PyList_Append(py_retlist, py_tuple)) goto error; - } Py_XDECREF(py_tuple); } return py_retlist; + error: Py_XDECREF(py_tuple); - Py_XDECREF(py_retlist); + Py_DECREF(py_retlist); return NULL; } |