]> granicus.if.org Git - procps-ng/commitdiff
misc: eliminate a couple of miscellaneous gcc warnings
authorJim Warner <james.warner@comcast.net>
Sun, 28 Jun 2020 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Sun, 5 Jul 2020 11:13:01 +0000 (21:13 +1000)
This commit just address the two warnings shown below.

Reference(s):
pgrep.c: In function `select_procs':
pgrep.c:535:12: warning: variable `now' set but not used [-Wunused-but-set-variable]
  535 |     time_t now;
      |            ^~~

pidof.c: In function `select_procs':
pidof.c:201:9: warning: `stat_cmd' may be used uninitialized in this function [-Wmaybe-uninitialized]
  201 |        !strcmp(program, stat_cmd) ||
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jim Warner <james.warner@comcast.net>
pgrep.c
pidof.c

diff --git a/pgrep.c b/pgrep.c
index a55f49f019000b852cd50381438e232653b30072..d753cc9107b45256b9408c791b57addccd981c44 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -529,12 +529,10 @@ static struct el * select_procs (int *num)
     char *cmdoutput = xmalloc(cmdlen);
     char *task_cmdline;
     enum pids_fetch_type which;
-    time_t now;
     double uptime_secs;
 
     preg = do_regcomp();
 
-    now = time(NULL);
     if (procps_uptime(&uptime_secs, NULL) < 0)
         xerrx(EXIT_FAILURE, "uptime");
 
diff --git a/pidof.c b/pidof.c
index 92456a0f63f23477cf81a9466c4594820ae66fdb..87a0858404ae2541082648c81750891f334a0530 100644 (file)
--- a/pidof.c
+++ b/pidof.c
@@ -145,7 +145,6 @@ static void select_procs (void)
        static int size = 0;
        char *cmd_arg0, *cmd_arg0base;
        char *cmd_arg1, *cmd_arg1base;
-       char *stat_cmd;
        char *program_base;
        char *root_link;
        char *exe_link;
@@ -196,9 +195,6 @@ static void select_procs (void)
                        if (!strcmp(program, cmd_arg0base) ||
                            !strcmp(program_base, cmd_arg0) ||
                            !strcmp(program, cmd_arg0) ||
-
-                           !strcmp(program, stat_cmd) ||
-
                            !strcmp(program, exe_link_base) ||
                            !strcmp(program, exe_link))
                        {