X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fipc.c;h=ab4b214d221338830b109e83bf837073a1d63ae2;hb=c4439c9cb3e2348ad7013644731de27a55eca478;hp=432c5e087d7e50c819b75fcb45b7955a29feaa6d;hpb=867ad628dc6fcd05bd584b605d7093cfc00c3d07;p=collectd.git diff --git a/src/ipc.c b/src/ipc.c index 432c5e08..ab4b214d 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -28,8 +28,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #if KERNEL_LINUX /* _GNU_SOURCE is needed for struct shm_info.used_ids on musl libc */ @@ -119,10 +119,9 @@ static int ipc_read_sem(void) /* {{{ */ status = semctl(/* id = */ 0, /* num = */ 0, SEM_INFO, arg); if (status == -1) { - char errbuf[1024]; ERROR("ipc plugin: semctl(2) failed: %s. " "Maybe the kernel is not configured for semaphores?", - sstrerror(errno, errbuf, sizeof(errbuf))); + STRERRNO); return -1; } @@ -139,10 +138,9 @@ static int ipc_read_shm(void) /* {{{ */ status = shmctl(/* id = */ 0, SHM_INFO, (void *)&shm_info); if (status == -1) { - char errbuf[1024]; ERROR("ipc plugin: shmctl(2) failed: %s. " "Maybe the kernel is not configured for shared memory?", - sstrerror(errno, errbuf, sizeof(errbuf))); + STRERRNO); return -1; } @@ -187,9 +185,7 @@ static caddr_t ipc_get_info(cid_t cid, int cmd, int version, int stsize, if (get_ipc_info(cid, cmd, version, buff, &size) < 0) { if (errno != ENOSPC) { - char errbuf[1024]; - WARNING("ipc plugin: get_ipc_info: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("ipc plugin: get_ipc_info: %s", STRERRNO); return NULL; } } @@ -211,9 +207,7 @@ static caddr_t ipc_get_info(cid_t cid, int cmd, int version, int stsize, } if (get_ipc_info(cid, cmd, version, buff, &size) < 0) { - char errbuf[1024]; - WARNING("ipc plugin: get_ipc_info: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("ipc plugin: get_ipc_info: %s", STRERRNO); free(buff); return NULL; } @@ -251,14 +245,14 @@ static int ipc_read_shm(void) /* {{{ */ ipcinfo_shm_t *pshm; unsigned int shm_segments = 0; size64_t shm_bytes = 0; - int n; + int i, n; ipcinfo_shm = (ipcinfo_shm_t *)ipc_get_info( 0, GET_IPCINFO_SHM_ALL, IPCINFO_SHM_VERSION, sizeof(ipcinfo_shm_t), &n); if (ipcinfo_shm == NULL) return -1; - for (int i = 0, pshm = ipcinfo_shm; i < n; i++, pshm++) { + for (i = 0, pshm = ipcinfo_shm; i < n; i++, pshm++) { shm_segments++; shm_bytes += pshm->shm_segsz; }