X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fvserver.c;h=3c6d58cd867011355939005cbae0b9affc3cc274;hp=a2ca0de5dfc93109b2a4fa79d4a673b0792ede6b;hb=ec51ddee94fa2ba1e01fe0e336ccc9c190a198ff;hpb=6026e3162e522b133d10596710527d24c2921b55 diff --git a/src/vserver.c b/src/vserver.c index a2ca0de5..3c6d58cd 100644 --- a/src/vserver.c +++ b/src/vserver.c @@ -42,7 +42,7 @@ #error "No applicable input method." #endif -static int pagesize = 0; +static int pagesize; static int vserver_init(void) { /* XXX Should we check for getpagesize () in configure? @@ -124,9 +124,7 @@ static int vserver_read(void) { errno = 0; proc = opendir(PROCDIR); if (proc == NULL) { - char errbuf[1024]; - ERROR("vserver plugin: fopen (%s): %s", PROCDIR, - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("vserver plugin: fopen (%s): %s", PROCDIR, STRERRNO); return -1; } @@ -146,13 +144,11 @@ static int vserver_read(void) { errno = 0; dent = readdir(proc); if (dent == NULL) { - char errbuf[4096]; - if (errno == 0) /* end of directory */ break; ERROR("vserver plugin: failed to read directory %s: %s", PROCDIR, - sstrerror(errno, errbuf, sizeof(errbuf))); + STRERRNO); closedir(proc); return -1; } @@ -160,15 +156,13 @@ static int vserver_read(void) { if (dent->d_name[0] == '.') continue; - len = ssnprintf(file, sizeof(file), PROCDIR "/%s", dent->d_name); + len = snprintf(file, sizeof(file), PROCDIR "/%s", dent->d_name); if ((len < 0) || (len >= BUFSIZE)) continue; status = stat(file, &statbuf); if (status != 0) { - char errbuf[4096]; - WARNING("vserver plugin: stat (%s) failed: %s", file, - sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("vserver plugin: stat (%s) failed: %s", file, STRERRNO); continue; } @@ -176,14 +170,12 @@ static int vserver_read(void) { continue; /* socket message accounting */ - len = ssnprintf(file, sizeof(file), PROCDIR "/%s/cacct", dent->d_name); + len = snprintf(file, sizeof(file), PROCDIR "/%s/cacct", dent->d_name); if ((len < 0) || ((size_t)len >= sizeof(file))) continue; if (NULL == (fh = fopen(file, "r"))) { - char errbuf[1024]; - ERROR("Cannot open '%s': %s", file, - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("Cannot open '%s': %s", file, STRERRNO); } while ((fh != NULL) && (NULL != fgets(buffer, BUFSIZE, fh))) { @@ -220,14 +212,12 @@ static int vserver_read(void) { } /* thread information and load */ - len = ssnprintf(file, sizeof(file), PROCDIR "/%s/cvirt", dent->d_name); + len = snprintf(file, sizeof(file), PROCDIR "/%s/cvirt", dent->d_name); if ((len < 0) || ((size_t)len >= sizeof(file))) continue; if (NULL == (fh = fopen(file, "r"))) { - char errbuf[1024]; - ERROR("Cannot open '%s': %s", file, - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("Cannot open '%s': %s", file, STRERRNO); } while ((fh != NULL) && (NULL != fgets(buffer, BUFSIZE, fh))) { @@ -266,14 +256,12 @@ static int vserver_read(void) { } /* processes and memory usage */ - len = ssnprintf(file, sizeof(file), PROCDIR "/%s/limit", dent->d_name); + len = snprintf(file, sizeof(file), PROCDIR "/%s/limit", dent->d_name); if ((len < 0) || ((size_t)len >= sizeof(file))) continue; if (NULL == (fh = fopen(file, "r"))) { - char errbuf[1024]; - ERROR("Cannot open '%s': %s", file, - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("Cannot open '%s': %s", file, STRERRNO); } while ((fh != NULL) && (NULL != fgets(buffer, BUFSIZE, fh))) {