Skip to content

Commit

Permalink
small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 8, 2016
1 parent df490a9 commit b8cb12a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions psutil/arch/bsd/netbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ psutil_virtual_mem(PyObject *self, PyObject *args) {
struct uvmexp_sysctl uv;
int mib[] = {CTL_VM, VM_UVMEXP2};
long pagesize = getpagesize();
size = sizeof(uvmexp);
size = sizeof(uv);

if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {
if (sysctl(mib, 2, &uv, &size, NULL, 0) < 0) {
warn("failed to get vm.uvmexp");
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
Expand Down
9 changes: 6 additions & 3 deletions psutil/arch/bsd/openbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,13 @@ psutil_swap_mem(PyObject *self, PyObject *args) {
}

if ((swdev = calloc(nswap, sizeof(*swdev))) == NULL) {
PyErr_SetFromErrno(PyExc_OSError);
PyErr_NoMemory();
return NULL;
}

if (swapctl(SWAP_STATS, swdev, nswap) == -1) {
free(swdev);
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
goto error;
}

// Total things up.
Expand All @@ -417,6 +416,10 @@ psutil_swap_mem(PyObject *self, PyObject *args) {
// swapent struct does not provide any info
// about it.
0, 0);

error:
free(swdev);
return NULL;
}


Expand Down

0 comments on commit b8cb12a

Please sign in to comment.