Fixes multiple occurences of 'optarg' overwrites.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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);
}
/*
free(u);
}
-static int parse_time_mode(const char *optarg)
+static int parse_time_mode(const char *s)
{
struct lslogins_timefmt {
const char *name;
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)
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")) {
}
}
-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;
}
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
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) {
default:
err(EXIT_FAILURE, _("key failed"));
}
- warnx("%s (%s)", errmsg, optarg);
+ warnx("%s (%s)", errmsg, s);
}
return 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;
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)
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;