]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc: fix declarations shadowing variables in the global scope [oclint]
authorSami Kerola <kerolasa@iki.fi>
Sun, 3 Jul 2016 12:20:30 +0000 (13:20 +0100)
committerSami Kerola <kerolasa@iki.fi>
Thu, 21 Jul 2016 20:14:33 +0000 (21:14 +0100)
Fixes multiple occurences of 'optarg' overwrites.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/last.c
login-utils/lslogins.c
misc-utils/logger.c
sys-utils/dmesg.c
sys-utils/ipcrm.c
sys-utils/lsipc.c
sys-utils/rtcwake.c

index 0c234f5e441134b2fbd759776b40462225480c65..6d0e8920a6381467749573c5346ca453a0aad1fc 100644 (file)
@@ -163,15 +163,15 @@ static time_t lastdate;           /* Last date we've seen */
 static time_t currentdate;     /* date when we started processing the file */
 
 /* --time-format=option parser */
-static int which_time_format(const char *optarg)
+static int which_time_format(const char *s)
 {
        size_t i;
 
        for (i = 0; i < ARRAY_SIZE(timefmts); i++) {
-               if (strcmp(timefmts[i].name, optarg) == 0)
+               if (strcmp(timefmts[i].name, s) == 0)
                        return i;
        }
-       errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
+       errx(EXIT_FAILURE, _("unknown time format: %s"), s);
 }
 
 /*
index 60a1b500f236816ca0a5d0476080978684c5cf9d..76ada7fd2e789284ffe4533e4161b869e46e546e 100644 (file)
@@ -1200,7 +1200,7 @@ static void free_user(void *f)
        free(u);
 }
 
-static int parse_time_mode(const char *optarg)
+static int parse_time_mode(const char *s)
 {
        struct lslogins_timefmt {
                const char *name;
@@ -1214,10 +1214,10 @@ static int parse_time_mode(const char *optarg)
        size_t i;
 
        for (i = 0; i < ARRAY_SIZE(timefmts); i++) {
-               if (strcmp(timefmts[i].name, optarg) == 0)
+               if (strcmp(timefmts[i].name, s) == 0)
                        return timefmts[i].val;
        }
-       errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
+       errx(EXIT_FAILURE, _("unknown time format: %s"), s);
 }
 
 static void __attribute__((__noreturn__)) usage(FILE *out)
index dbb9cdc24ecd742d92bd9ef48eabf9209a167ddd..4fb650a42f7e75cbc92c4749193ce7d9af4761f0 100644 (file)
@@ -804,11 +804,11 @@ static void syslog_rfc5424_header(struct logger_ctl *const ctl)
        free(structured);
 }
 
-static void parse_rfc5424_flags(struct logger_ctl *ctl, char *optarg)
+static void parse_rfc5424_flags(struct logger_ctl *ctl, char *s)
 {
        char *in, *tok;
 
-       in = optarg;
+       in = s;
        while ((tok = strtok(in, ","))) {
                in = NULL;
                if (!strcmp(tok, "notime")) {
@@ -823,15 +823,15 @@ static void parse_rfc5424_flags(struct logger_ctl *ctl, char *optarg)
        }
 }
 
-static int parse_unix_socket_errors_flags(char *optarg)
+static int parse_unix_socket_errors_flags(char *s)
 {
-       if (!strcmp(optarg, "off"))
+       if (!strcmp(s, "off"))
                return AF_UNIX_ERRORS_OFF;
-       if (!strcmp(optarg, "on"))
+       if (!strcmp(s, "on"))
                return AF_UNIX_ERRORS_ON;
-       if (!strcmp(optarg, "auto"))
+       if (!strcmp(s, "auto"))
                return AF_UNIX_ERRORS_AUTO;
-       warnx(_("invalid argument: %s: using automatic errors"), optarg);
+       warnx(_("invalid argument: %s: using automatic errors"), s);
        return AF_UNIX_ERRORS_AUTO;
 }
 
index 92de6e26fd59d17e791130b7965c2717233dda18..a2ab3a2e3220b73c5799cc7c828768ac86cfc92a 100644 (file)
@@ -1178,19 +1178,19 @@ static int read_kmsg(struct dmesg_control *ctl)
        return 0;
 }
 
-static int which_time_format(const char *optarg)
+static int which_time_format(const char *s)
 {
-       if (!strcmp(optarg, "notime"))
+       if (!strcmp(s, "notime"))
                return DMESG_TIMEFTM_NONE;
-       if (!strcmp(optarg, "ctime"))
+       if (!strcmp(s, "ctime"))
                return DMESG_TIMEFTM_CTIME;
-       if (!strcmp(optarg, "delta"))
+       if (!strcmp(s, "delta"))
                return DMESG_TIMEFTM_DELTA;
-       if (!strcmp(optarg, "reltime"))
+       if (!strcmp(s, "reltime"))
                return DMESG_TIMEFTM_RELTIME;
-       if (!strcmp(optarg, "iso"))
+       if (!strcmp(s, "iso"))
                return DMESG_TIMEFTM_ISO8601;
-       errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
+       errx(EXIT_FAILURE, _("unknown time format: %s"), s);
 }
 
 #ifdef TEST_DMESG
index 7912feed9f5efb3ad21057b2280ce2179d1cd014..06bbd446bfce0de530834f2e81bdbf0e3e70bbfe 100644 (file)
@@ -191,13 +191,13 @@ static unsigned long strtokey(const char *str, const char *errmesg)
        return 0;
 }
 
-static int key_to_id(type_id type, char *optarg)
+static int key_to_id(type_id type, char *s)
 {
        int id;
        /* keys are in hex or decimal */
-       key_t key = strtokey(optarg, "failed to parse argument");
+       key_t key = strtokey(s, "failed to parse argument");
        if (key == IPC_PRIVATE) {
-               warnx(_("illegal key (%s)"), optarg);
+               warnx(_("illegal key (%s)"), s);
                return -1;
        }
        switch (type) {
@@ -230,7 +230,7 @@ static int key_to_id(type_id type, char *optarg)
                default:
                        err(EXIT_FAILURE, _("key failed"));
                }
-               warnx("%s (%s)", errmsg, optarg);
+               warnx("%s (%s)", errmsg, s);
        }
        return id;
 }
index 9041dc17b9b31f7cd626b9a7ecb6c96a133b4649..d4e5037adc8de712579b99e493448d699105e6cf 100644 (file)
@@ -249,7 +249,7 @@ static char *get_groupname(struct group **gr, gid_t id)
        return *gr ? xstrdup((*gr)->gr_name) : NULL;
 }
 
-static int parse_time_mode(const char *optarg)
+static int parse_time_mode(const char *s)
 {
        struct lsipc_timefmt {
                const char *name;
@@ -263,10 +263,10 @@ static int parse_time_mode(const char *optarg)
        size_t i;
 
        for (i = 0; i < ARRAY_SIZE(timefmts); i++) {
-               if (strcmp(timefmts[i].name, optarg) == 0)
+               if (strcmp(timefmts[i].name, s) == 0)
                        return timefmts[i].val;
        }
-       errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
+       errx(EXIT_FAILURE, _("unknown time format: %s"), s);
 }
 
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
index 053baf5efaea975ec272d46fba8f50089d7b9456..536c5bf5c28397c73810792b1f8f800dfbb58149 100644 (file)
@@ -344,18 +344,18 @@ static int print_alarm(struct rtcwake_control *ctl, int fd)
        return 0;
 }
 
-static int get_rtc_mode(struct rtcwake_control *ctl, const char *optarg)
+static int get_rtc_mode(struct rtcwake_control *ctl, const char *s)
 {
        size_t i;
        char **modes = get_sys_power_states(ctl), **m;
 
        STRV_FOREACH(m, modes) {
-               if (strcmp(optarg, *m) == 0)
+               if (strcmp(s, *m) == 0)
                        return SYSFS_MODE;
        }
 
        for (i = 0; i < ARRAY_SIZE(rtcwake_mode_string); i++)
-               if (!strcmp(optarg, rtcwake_mode_string[i]))
+               if (!strcmp(s, rtcwake_mode_string[i]))
                        return i;
 
        return -EINVAL;