Skip to content

Commit

Permalink
#916: [OSX] fix many compilation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 12, 2016
1 parent c2670aa commit 79356b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Expand Up @@ -33,6 +33,7 @@ Bug tracker at https://github.com/giampaolo/psutil/issues
instead of OSError and RuntimeError.
- #909: [OSX] Process open_files() and connections() methods may raise
OSError with no exception set if process is gone.
- #916: [OSX] fix many compilation warnings.


4.3.1 - 2016-09-01
Expand Down
18 changes: 9 additions & 9 deletions psutil/_psutil_osx.c
Expand Up @@ -172,7 +172,7 @@ psutil_proc_exe(PyObject *self, PyObject *args) {
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;
errno = 0;
ret = proc_pidpath(pid, &buf, sizeof(buf));
ret = proc_pidpath((pid_t)pid, &buf, sizeof(buf));
if (ret == 0) {
psutil_raise_for_pid(pid, "proc_pidpath() syscall failed");
return NULL;
Expand Down Expand Up @@ -311,7 +311,7 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) {
if (! PyArg_ParseTuple(args, "l", &pid))
goto error;

err = task_for_pid(mach_task_self(), pid, &task);
err = task_for_pid(mach_task_self(), (pid_t)pid, &task);
if (err != KERN_SUCCESS) {
if (psutil_pid_exists(pid) == 0)
NoSuchProcess();
Expand Down Expand Up @@ -354,7 +354,7 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) {
// so we do what we can in order to not continue in case
// of error.
errno = 0;
proc_regionfilename(pid, address, buf, sizeof(buf));
proc_regionfilename((pid_t)pid, address, buf, sizeof(buf));
if ((errno != 0) || ((sizeof(buf)) <= 0)) {
psutil_raise_for_pid(
pid, "proc_regionfilename() syscall failed");
Expand Down Expand Up @@ -593,7 +593,7 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) {
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;

err = task_for_pid(mach_task_self(), pid, &task);
err = task_for_pid(mach_task_self(), (pid_t)pid, &task);
if (err != KERN_SUCCESS) {
if (psutil_pid_exists(pid) == 0)
NoSuchProcess();
Expand Down Expand Up @@ -1051,7 +1051,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
goto error;

// task_for_pid() requires special privileges
err = task_for_pid(mach_task_self(), pid, &task);
err = task_for_pid(mach_task_self(), (pid_t)pid, &task);
if (err != KERN_SUCCESS) {
if (psutil_pid_exists(pid) == 0)
NoSuchProcess();
Expand Down Expand Up @@ -1181,7 +1181,7 @@ psutil_proc_open_files(PyObject *self, PyObject *args) {

if (fdp_pointer->proc_fdtype == PROX_FDTYPE_VNODE) {
errno = 0;
nb = proc_pidfdinfo(pid,
nb = proc_pidfdinfo((pid_t)pid,
fdp_pointer->proc_fd,
PROC_PIDFDVNODEPATHINFO,
&vi,
Expand Down Expand Up @@ -1301,7 +1301,7 @@ psutil_proc_connections(PyObject *self, PyObject *args) {

if (fdp_pointer->proc_fdtype == PROX_FDTYPE_SOCKET) {
errno = 0;
nb = proc_pidfdinfo(pid, fdp_pointer->proc_fd,
nb = proc_pidfdinfo((pid_t)pid, fdp_pointer->proc_fd,
PROC_PIDFDSOCKETINFO, &si, sizeof(si));

// --- errors checking
Expand Down Expand Up @@ -1445,14 +1445,14 @@ psutil_proc_num_fds(PyObject *self, PyObject *args) {
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;

pidinfo_result = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0);
pidinfo_result = proc_pidinfo((pid_t)pid, PROC_PIDLISTFDS, 0, NULL, 0);
if (pidinfo_result <= 0)
return PyErr_SetFromErrno(PyExc_OSError);

fds_pointer = malloc(pidinfo_result);
if (fds_pointer == NULL)
return PyErr_NoMemory();
pidinfo_result = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, fds_pointer,
pidinfo_result = proc_pidinfo((pid_t)pid, PROC_PIDLISTFDS, 0, fds_pointer,
pidinfo_result);
if (pidinfo_result <= 0) {
free(fds_pointer);
Expand Down
8 changes: 4 additions & 4 deletions psutil/arch/osx/process_info.c
Expand Up @@ -140,7 +140,7 @@ psutil_get_cmdline(long pid) {
// read argument space
mib[0] = CTL_KERN;
mib[1] = KERN_PROCARGS2;
mib[2] = pid;
mib[2] = (pid_t)pid;
if (sysctl(mib, 3, procargs, &argmax, NULL, 0) < 0) {
if (EINVAL == errno) {
// EINVAL == access denied OR nonexistent PID
Expand Down Expand Up @@ -239,7 +239,7 @@ psutil_get_environ(long pid) {
// read argument space
mib[0] = CTL_KERN;
mib[1] = KERN_PROCARGS2;
mib[2] = pid;
mib[2] = (pid_t)pid;
if (sysctl(mib, 3, procargs, &argmax, NULL, 0) < 0) {
if (EINVAL == errno) {
// EINVAL == access denied OR nonexistent PID
Expand Down Expand Up @@ -325,13 +325,13 @@ psutil_get_environ(long pid) {


int
psutil_get_kinfo_proc(pid_t pid, struct kinfo_proc *kp) {
psutil_get_kinfo_proc(long pid, struct kinfo_proc *kp) {
int mib[4];
size_t len;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = pid;
mib[3] = (pid_t)pid;

// fetch the info with sysctl()
len = sizeof(struct kinfo_proc);
Expand Down
2 changes: 1 addition & 1 deletion psutil/arch/osx/process_info.h
Expand Up @@ -9,7 +9,7 @@
typedef struct kinfo_proc kinfo_proc;

int psutil_get_argmax(void);
int psutil_get_kinfo_proc(pid_t pid, struct kinfo_proc *kp);
int psutil_get_kinfo_proc(long pid, struct kinfo_proc *kp);
int psutil_get_proc_list(kinfo_proc **procList, size_t *procCount);
int psutil_proc_pidinfo(
long pid, int flavor, uint64_t arg, void *pti, int size);
Expand Down

0 comments on commit 79356b3

Please sign in to comment.