summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2014-04-24 12:15:56 -0300
committerHisham Muhammad <hisham@gobolinux.org>2014-04-24 12:15:56 -0300
commit34b89a97472f033f02ae872ca557417f9cfdcd62 (patch)
tree88fb911905576269934ec3ee85878442a635b839
parent823bdbae133afcb00718ab50af85186df2e7b155 (diff)
Add sanity checks.
-rw-r--r--ProcessList.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ProcessList.c b/ProcessList.c
index 3d6341c4..908d88fc 100644
--- a/ProcessList.c
+++ b/ProcessList.c
@@ -217,7 +217,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) {
fgets(buffer, 255, file);
} while (String_startsWith(buffer, "cpu"));
fclose(file);
- this->cpuCount = cpus - 1;
+ this->cpuCount = MAX(cpus - 1, 1);
#ifdef HAVE_LIBHWLOC
this->topologyOk = false;
@@ -724,7 +724,7 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
time_t curTime = tv.tv_sec;
#ifdef HAVE_TASKSTATS
- unsigned long long now = tv.tv_sec*1000+tv.tv_usec/1000;
+ unsigned long long now = tv.tv_sec*1000LL+tv.tv_usec/1000LL;
#endif
dir = opendir(dirname);
@@ -884,6 +884,7 @@ void ProcessList_scan(ProcessList* this) {
CRT_fatalError("Cannot open " PROCMEMINFOFILE);
}
int cpus = this->cpuCount;
+ assert(cpus > 0);
{
char buffer[128];
while (fgets(buffer, 128, file)) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy