diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2018-03-30 21:13:50 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2018-03-30 21:13:50 +0200 |
commit | df32f954878169c396aae4dd9b70beb11f9c61a1 (patch) | |
tree | 9f42b08628f78b1f273337ee30bb0c044fe06cfc | |
parent | e1b67065e2a9383789e4cac333088fd5725ddd2f (diff) | |
download | psutil-df32f954878169c396aae4dd9b70beb11f9c61a1.tar.gz |
error out if get_num_cpus() fail
-rw-r--r-- | psutil/_psutil_windows.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index a1f555b3..3a281692 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -1010,7 +1010,7 @@ psutil_per_cpu_times(PyObject *self, PyObject *args) { goto error; } - // retrives number of processors + // retrieves number of processors ncpus = psutil_get_num_cpus(1); if (ncpus == 0) goto error; @@ -3453,7 +3453,7 @@ psutil_cpu_stats(PyObject *self, PyObject *args) { goto error; } - // retrives number of processors + // retrieves number of processors ncpus = psutil_get_num_cpus(1); if (ncpus == 0) goto error; @@ -3558,12 +3558,9 @@ psutil_cpu_freq(PyObject *self, PyObject *args) { unsigned int ncpus; // Get the number of CPUs. - ncpus = psutil_get_num_cpus(0); - if (ncpus == 0) { - psutil_debug("psutil_get_num_cpus() returned error; ignoring it" - "and assume num_cpus = 1"); - ncpus = 1; - } + ncpus = psutil_get_num_cpus(1); + if (ncpus == 0) + return NULL; // Allocate size. size = ncpus * sizeof(PROCESSOR_POWER_INFORMATION); |