]> granicus.if.org Git - procps-ng/commitdiff
misc: eliminate all those remaining gcc -Wall warnings
authorJim Warner <james.warner@comcast.net>
Sat, 13 May 2017 05:01:00 +0000 (00:01 -0500)
committerCraig Small <csmall@enc.com.au>
Mon, 22 May 2017 11:34:32 +0000 (21:34 +1000)
Reference(s):
proc/readproc.c: In function 'statm2proc'
proc/readproc.c:627:9: warning: variable 'num' set but not used [-Wunused-but-set-variable]

ps/output.c: In function 'pr_context':
ps/output.c:1273:14: warning: unused variable 'tried_load' [-Wunused-variable]
ps/output.c:1272:16: warning: unused variable 'ps_is_selinux_enabled' [-Wunused-variable]
ps/output.c:1272:16: warning: 'ps_is_selinux_enabled' defined but not used [-Wunused-variable]
ps/output.c:1273:14: warning: 'tried_load' defined but not used [-Wunused-variable]
ps/output.c:1837:18: warning: 'shortsort_array_count' defined but not used [-Wunused-const-variable=]
ps/output.c:1803:18: warning: 'aix_array_count' defined but not used [-Wunused-const-variable=]

ps/parser.c: In function 'arg_type':
ps/parser.c:1098:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
ps/parser.c:1099:34: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'

ps/sortformat.c: In function 'format_parse':
ps/sortformat.c:241:1: warning: label 'out' defined but not used [-Wunused-label]

ps/stacktrace.c:176:13: warning: 'stack_trace_sigsegv' defined but not used [-Wunused-function]

watch.c: In function 'process_ansi':
watch.c:234:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
watch.c:237:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'

Signed-off-by: Jim Warner <james.warner@comcast.net>
free.c
proc/readproc.c
ps/output.c
ps/parser.c
ps/sortformat.c
ps/stacktrace.c
watch.c

diff --git a/free.c b/free.c
index 3db0b59eb14a63da87addf7d8866d7ff78f94b03..91fa4c71d91ea319bcf2254cef50fd8668aca5fe 100644 (file)
--- a/free.c
+++ b/free.c
@@ -202,7 +202,6 @@ static void check_unit_set(int *unit_set)
 int main(int argc, char **argv)
 {
        int c, flags = 0, unit_set = 0;
-       char *endptr;
        struct commandline_arguments args;
 
        /*
index 48b56f67c279e5d2ffe8e4a5ce0284bf20c9b6e0..0a30edee74a04a3ef1127e903f64de19c0da9602 100644 (file)
@@ -624,11 +624,9 @@ LEAVE(0x160);
 /////////////////////////////////////////////////////////////////////////
 
 static void statm2proc(const char* s, proc_t *restrict P) {
-    int num;
-    num = sscanf(s, "%ld %ld %ld %ld %ld %ld %ld",
+    sscanf(s, "%ld %ld %ld %ld %ld %ld %ld",
           &P->size, &P->resident, &P->share,
           &P->trs, &P->lrs, &P->drs, &P->dt);
-/*    fprintf(stderr, "statm2proc converted %d fields.\n",num); */
 }
 
 static int file2str(const char *directory, const char *what, struct utlbuf_s *ub) {
index 8c6a52892c3abe30793a1c213d8ec0fd9953b5d9..f9a29bf6ff46358d61029eea5b0bbb15dfeae504 100644 (file)
@@ -1262,13 +1262,14 @@ static int pr_lxcname(char *restrict const outbuf, const proc_t *restrict const
 static int pr_context(char *restrict const outbuf, const proc_t *restrict const pp){
   static void (*ps_freecon)(char*) = 0;
   static int (*ps_getpidcon)(pid_t pid, char **context) = 0;
-  static int (*ps_is_selinux_enabled)(void) = 0;
-  static int tried_load = 0;
-  static int selinux_enabled = 0;
+  static int selinux_enabled = 0;;
   size_t len;
   char *context;
 
 #if ENABLE_LIBSELINUX
+  static int (*ps_is_selinux_enabled)(void) = 0;
+  static int tried_load = 0;
+
   if(!ps_getpidcon && !tried_load){
     void *handle = dlopen("libselinux.so.1", RTLD_NOW);
     if(handle){
@@ -1792,7 +1793,7 @@ static const aix_struct aix_array[] = {
 {'z', "vsz",    "VSZ"},
 {'~', "~",      "~"} /* NULL would ruin alphabetical order */
 };
-static const int aix_array_count = sizeof(aix_array)/sizeof(aix_struct);
+//static const int aix_array_count = sizeof(aix_array)/sizeof(aix_struct);
 
 
 /********************* sorting ***************************/
@@ -1826,7 +1827,7 @@ static const shortsort_struct shortsort_array[] = {
 {'y', "priority"   }, /* nice */
 {'~', "~"          } /* NULL would ruin alphabetical order */
 };
-static const int shortsort_array_count = sizeof(shortsort_array)/sizeof(shortsort_struct);
+//static const int shortsort_array_count = sizeof(shortsort_array)/sizeof(shortsort_struct);
 
 
 /*********** print format_array **********/
index 8d533b38f9d7ab3ab9c74cb87c857b65c7f451cc..4287d074addef04ddc219e53c8d6c50b7db8a25b 100644 (file)
@@ -1096,7 +1096,7 @@ static int arg_type(const char *str){
   if((tmp>='a') && (tmp<='z'))   return ARG_GNU;
   if((tmp>='A') && (tmp<='Z'))   return ARG_GNU;
   if(tmp=='\0')                  return ARG_END;
-                                 return ARG_FAIL;
+  return ARG_FAIL;
 }
 
 /* First assume sysv, because that is the POSIX and Unix98 standard. */
index 5ffc25b241db291336d9948d55751e0fb6504853..ace5fa704402ceb8e9c8b2f8dc22a00fba809cda 100644 (file)
@@ -238,7 +238,7 @@ static const char *format_parse(sf_node *sfn){
       need_item=0;
     }
   } while (*++walk);
-out:
+
   if(!items){
     free(buf);
     goto empty;
index a0b4755cb6be24a84d8874a773db93851fc79784..01ea217d4cd78e0c420a3ce78dc3689a2d8e5bc7 100644 (file)
@@ -173,10 +173,12 @@ void debug(int method, char *prog_name){
 }
 
 /************/
+#if 0
 static void stack_trace_sigsegv(int signum){
   (void)signum;
   debug(STACK_TRACE, stored_prog_name);
 }
+#endif
 
 /************/
 #ifdef DEBUG
diff --git a/watch.c b/watch.c
index 215b4bf544aa2f284cc8c4f0c7b376ea7138459b..e8bfb75fb2da8f455a5dcfde78e569c639f96cd4 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -234,8 +234,8 @@ static void process_ansi(FILE * fp)
     if (buf[0] == '\0')
         set_ansi_attribute(0);
 
-       for (endptr = numstart = buf; *endptr != '\0'; numstart = endptr + 1) {
-               if (!set_ansi_attribute(strtol(numstart, &endptr, 10)))
+    for (endptr = numstart = buf; *endptr != '\0'; numstart = endptr + 1) {
+        if (!set_ansi_attribute(strtol(numstart, &endptr, 10)))
             break;
     }
 }