From 88daa89883a53a0672d39512616b43849235467a Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 7 Sep 2015 00:00:00 -0500 Subject: [PATCH] miscellaneous: silence a whole bunch of clang warnings [ but most definitely not all of them by a long shot ] Reference(s): proc/diskstat.c:186:17: warning: unused variable 'is_disk' [-Wunused-variable] int retval, is_disk; ^ proc/namespace.c:110:1: warning: control may reach end of non-void function [-Wreturn-type] } ^ proc/readproc.c:1131:50: warning: address of array 'ent->d_name' will always evaluate to 'true' [-Wpointer-bo if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0; ~~~~~~^~~~~~ proc/readproc.c:1158:50: warning: address of array 'ent->d_name' will always evaluate to 'true' [-Wpointer-bo if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0; ~~~~~~^~~~~~ proc/sysinfo.c:45:12: warning: unused variable 'stat_fd' [-Wunused-variable] static int stat_fd = -1; ^ proc/sysinfo.c:49:12: warning: unused variable 'meminfo_fd' [-Wunused-variable] static int meminfo_fd = -1; ^ proc/sysinfo.c:51:12: warning: unused variable 'vminfo_fd' [-Wunused-variable] static int vminfo_fd = -1; ^ proc/sysinfo.c:53:12: warning: unused variable 'vm_min_free_fd' [-Wunused-variable] static int vm_min_free_fd = -1; ^ proc/uptime.c:157:12: warning: unused variable 'realseconds' [-Wunused-variable] time_t realseconds; ^ proc/uptime.c:158:16: warning: unused variable 'realtime' [-Wunused-variable] struct tm *realtime; ^ vmstat.c:574:20: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat] DSTAT(PROCPS_DISKSTAT_READ_TIME), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vmstat.c:578:20: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat] DSTAT(PROCPS_DISKSTAT_WRITE_TIME), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ watch.c:230:7: warning: variable 'endptr' is uninitialized when used here [-Wuninitialized] if (*endptr == '\0') set_ansi_attribute(0); /* [m treated as [0m */ ^~~~~~ Signed-off-by: Jim Warner --- proc/diskstat.c | 2 +- proc/namespace.c | 1 + proc/readproc.c | 4 ++-- proc/sysinfo.c | 8 -------- proc/uptime.c | 2 -- vmstat.c | 2 +- watch.c | 2 +- 7 files changed, 6 insertions(+), 15 deletions(-) diff --git a/proc/diskstat.c b/proc/diskstat.c index 1a7d50c1..2b8409b0 100644 --- a/proc/diskstat.c +++ b/proc/diskstat.c @@ -183,7 +183,7 @@ PROCPS_EXPORT int procps_diskstat_new ( PROCPS_EXPORT int procps_diskstat_read ( struct procps_diskstat *info) { - int retval, is_disk; + int retval; char buf[DISKSTAT_LINE_LEN]; char devname[DISKSTAT_NAME_LEN]; struct procps_diskstat_dev *disk; diff --git a/proc/namespace.c b/proc/namespace.c index d61b1b6f..cd4f47d5 100644 --- a/proc/namespace.c +++ b/proc/namespace.c @@ -107,4 +107,5 @@ PROCPS_EXPORT int procps_ns_read_pid( else nsp->ns[i] = 0; } + return 0; } diff --git a/proc/readproc.c b/proc/readproc.c index 9036f11c..0d2eb7cb 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -1128,7 +1128,7 @@ static int simple_nextpid(PROCTAB *restrict const PT, proc_t *restrict const p) char *restrict const path = PT->path; for (;;) { ent = readdir(PT->procfs); - if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0; + if(unlikely(unlikely(!ent) || unlikely(!ent->d_name[0]))) return 0; if(likely(likely(*ent->d_name > '0') && likely(*ent->d_name <= '9'))) break; } p->tgid = strtoul(ent->d_name, NULL, 10); @@ -1155,7 +1155,7 @@ static int simple_nexttid(PROCTAB *restrict const PT, const proc_t *restrict con } for (;;) { ent = readdir(PT->taskdir); - if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0; + if(unlikely(unlikely(!ent) || unlikely(!ent->d_name[0]))) return 0; if(likely(likely(*ent->d_name > '0') && likely(*ent->d_name <= '9'))) break; } t->tid = strtoul(ent->d_name, NULL, 10); diff --git a/proc/sysinfo.c b/proc/sysinfo.c index c9dc9f3c..f58d139c 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -41,16 +41,8 @@ " proc /proc proc defaults\n" \ " In the meantime, run \"mount proc /proc -t proc\"\n" -#define STAT_FILE "/proc/stat" -static int stat_fd = -1; #define LOADAVG_FILE "/proc/loadavg" static int loadavg_fd = -1; -#define MEMINFO_FILE "/proc/meminfo" -static int meminfo_fd = -1; -#define VMINFO_FILE "/proc/vmstat" -static int vminfo_fd = -1; -#define VM_MIN_FREE_FILE "/proc/sys/vm/min_free_kbytes" -static int vm_min_free_fd = -1; // As of 2.6.24 /proc/meminfo seems to need 888 on 64-bit, // and would need 1258 if the obsolete fields were there. diff --git a/proc/uptime.c b/proc/uptime.c index e6412052..c692fd0e 100644 --- a/proc/uptime.c +++ b/proc/uptime.c @@ -154,8 +154,6 @@ PROCPS_EXPORT char *procps_uptime_sprint_short(void) int updecades, upyears, upweeks, updays, uphours, upminutes; int pos = 3; int comma = 0; - time_t realseconds; - struct tm *realtime; double uptime_secs, idle_secs; shortbuf[0] = '\0'; diff --git a/vmstat.c b/vmstat.c index 81579449..f53eaac9 100644 --- a/vmstat.c +++ b/vmstat.c @@ -542,7 +542,7 @@ static void diskformat(void) struct tm *tm_ptr; char timebuf[32]; const char format[] = "%-5s %6lu %6lu %7lu %7lu %6lu %6lu %7lu %7lu %6lu %6lu"; - const char wide_format[] = "%-5s %9lu %9lu %lu %1u %9lu %9lu %lu %1u %7lu %7lu"; + const char wide_format[] = "%-5s %9lu %9lu %lu %lu %9lu %9lu %lu %lu %7lu %7lu"; if (procps_diskstat_new(&disk_stat) < 0) xerr(EXIT_FAILURE, diff --git a/watch.c b/watch.c index 40beacad..b7dd4412 100644 --- a/watch.c +++ b/watch.c @@ -198,7 +198,7 @@ static void process_ansi(FILE * fp) { int i, c; char buf[MAX_ANSIBUF]; - char *numstart, *endptr; + char *numstart, *endptr = buf; c = getc(fp); if (c != '[') {