Coverity fixes: src/platform_linux.cc
This commit is contained in:
parent
6eb0b6ac27
commit
7a706e4206
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
|
|
||||||
|
static char buf[MAXPATHLEN + 1];
|
||||||
|
|
||||||
int OS::GetMemory(size_t *rss, size_t *vsize) {
|
int OS::GetMemory(size_t *rss, size_t *vsize) {
|
||||||
FILE *f = fopen("/proc/self/stat", "r");
|
FILE *f = fopen("/proc/self/stat", "r");
|
||||||
@ -14,70 +15,69 @@ int OS::GetMemory(size_t *rss, size_t *vsize) {
|
|||||||
|
|
||||||
int itmp;
|
int itmp;
|
||||||
char ctmp;
|
char ctmp;
|
||||||
char buffer[MAXPATHLEN];
|
|
||||||
size_t page_size = getpagesize();
|
size_t page_size = getpagesize();
|
||||||
|
|
||||||
/* PID */
|
/* PID */
|
||||||
if (fscanf(f, "%d ", &itmp) == 0) goto error;
|
if (fscanf(f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Exec file */
|
/* Exec file */
|
||||||
if (fscanf (f, "%s ", &buffer[0]) == 0) goto error;
|
if (fscanf (f, "%s ", buf) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* State */
|
/* State */
|
||||||
if (fscanf (f, "%c ", &ctmp) == 0) goto error;
|
if (fscanf (f, "%c ", &ctmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Parent process */
|
/* Parent process */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Process group */
|
/* Process group */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Session id */
|
/* Session id */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* TTY */
|
/* TTY */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* TTY owner process group */
|
/* TTY owner process group */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Flags */
|
/* Flags */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Minor faults (no memory page) */
|
/* Minor faults (no memory page) */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Minor faults, children */
|
/* Minor faults, children */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Major faults (memory page faults) */
|
/* Major faults (memory page faults) */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Major faults, children */
|
/* Major faults, children */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* utime */
|
/* utime */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* stime */
|
/* stime */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* utime, children */
|
/* utime, children */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* stime, children */
|
/* stime, children */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* jiffies remaining in current time slice */
|
/* jiffies remaining in current time slice */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* 'nice' value */
|
/* 'nice' value */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* jiffies until next timeout */
|
/* jiffies until next timeout */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* jiffies until next SIGALRM */
|
/* jiffies until next SIGALRM */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* start time (jiffies since system boot) */
|
/* start time (jiffies since system boot) */
|
||||||
if (fscanf (f, "%d ", &itmp) == 0) goto error;
|
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
|
|
||||||
/* Virtual memory size */
|
/* Virtual memory size */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
*vsize = (size_t) itmp;
|
*vsize = (size_t) itmp;
|
||||||
|
|
||||||
/* Resident set size */
|
/* Resident set size */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
*rss = (size_t) itmp * page_size;
|
*rss = (size_t) itmp * page_size;
|
||||||
|
|
||||||
/* rlim */
|
/* rlim */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Start of text */
|
/* Start of text */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* End of text */
|
/* End of text */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
/* Start of stack */
|
/* Start of stack */
|
||||||
if (fscanf (f, "%u ", &itmp) == 0) goto error;
|
if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user