mirror of https://github.com/xzeldon/htop.git
Silence warnings reported in #70.
This commit is contained in:
parent
5ca9b8e002
commit
50000d808e
|
@ -117,7 +117,8 @@ static ACPresence procAcpiCheck() {
|
||||||
}
|
}
|
||||||
|
|
||||||
char line[100];
|
char line[100];
|
||||||
fgets(line, sizeof line, file);
|
char* ok = fgets(line, sizeof line, file);
|
||||||
|
if (!ok) continue;
|
||||||
line[sizeof(line) - 1] = '\0';
|
line[sizeof(line) - 1] = '\0';
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
|
@ -344,7 +344,7 @@ static void LinuxProcessList_readOpenVZData(ProcessList* this, Process* process,
|
||||||
FILE* file = fopen(filename, "r");
|
FILE* file = fopen(filename, "r");
|
||||||
if (!file)
|
if (!file)
|
||||||
return;
|
return;
|
||||||
fscanf(file,
|
(void) fscanf(file,
|
||||||
"%*32u %*32s %*1c %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
"%*32u %*32s %*1c %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
||||||
"%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
"%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
||||||
"%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
"%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
||||||
|
@ -692,7 +692,8 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
|
||||||
// Dependending on your kernel version,
|
// Dependending on your kernel version,
|
||||||
// 5, 7, 8 or 9 of these fields will be set.
|
// 5, 7, 8 or 9 of these fields will be set.
|
||||||
// The rest will remain at zero.
|
// The rest will remain at zero.
|
||||||
fgets(buffer, 255, file);
|
char* ok = fgets(buffer, 255, file);
|
||||||
|
if (!ok) buffer[0] = '\0';
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
|
sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -80,8 +80,9 @@ int Platform_getUptime() {
|
||||||
double uptime = 0;
|
double uptime = 0;
|
||||||
FILE* fd = fopen(PROCDIR "/uptime", "r");
|
FILE* fd = fopen(PROCDIR "/uptime", "r");
|
||||||
if (fd) {
|
if (fd) {
|
||||||
fscanf(fd, "%64lf", &uptime);
|
int n = fscanf(fd, "%64lf", &uptime);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
if (n <= 0) return 0;
|
||||||
}
|
}
|
||||||
return (int) floor(uptime);
|
return (int) floor(uptime);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,7 @@ int Platform_getMaxPid() {
|
||||||
FILE* file = fopen(PROCDIR "/sys/kernel/pid_max", "r");
|
FILE* file = fopen(PROCDIR "/sys/kernel/pid_max", "r");
|
||||||
if (!file) return -1;
|
if (!file) return -1;
|
||||||
int maxPid = 4194303;
|
int maxPid = 4194303;
|
||||||
fscanf(file, "%32d", &maxPid);
|
(void) fscanf(file, "%32d", &maxPid);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return maxPid;
|
return maxPid;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue