summaryrefslogtreecommitdiffstats
path: root/misc-utils/cal.c
diff options
context:
space:
mode:
authorKarel Zak2016-10-07 15:24:32 +0200
committerKarel Zak2016-10-07 15:24:32 +0200
commitc49fb9cacdce5ba5c26793f5375e7778fb41601d (patch)
treec55a4b2fb5de1aec72dd75af6b8d316559533423 /misc-utils/cal.c
parentdocs: update AUTHORS file (diff)
downloadkernel-qcow2-util-linux-c49fb9cacdce5ba5c26793f5375e7778fb41601d.tar.gz
kernel-qcow2-util-linux-c49fb9cacdce5ba5c26793f5375e7778fb41601d.tar.xz
kernel-qcow2-util-linux-c49fb9cacdce5ba5c26793f5375e7778fb41601d.zip
cal: remove err message from monthname_to_number()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/cal.c')
-rw-r--r--misc-utils/cal.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index ee8fafb7c..aaa2943e6 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -429,8 +429,12 @@ int main(int argc, char **argv)
case 2:
if (isdigit(**argv))
ctl.req.month = strtos32_or_err(*argv++, _("illegal month value: use 1-12"));
- else
- ctl.req.month = monthname_to_number(&ctl, *argv++);
+ else {
+ ctl.req.month = monthname_to_number(&ctl, *argv);
+ if (ctl.req.month < 0)
+ errx(EXIT_FAILURE, _("unknown month name: %s"), *argv);
+ argv++;
+ }
if (ctl.req.month < 1 || MONTHS_IN_YEAR < ctl.req.month)
errx(EXIT_FAILURE, _("illegal month value: use 1-12"));
/* FALLTHROUGH */
@@ -549,7 +553,7 @@ static int monthname_to_number(struct cal_control *ctl, const char *name)
if (strcasecmp(ctl->full_month[i], name) == 0)
return i + 1;
- errx(EXIT_FAILURE, _("unknown month name: %s"), name);
+ return -EINVAL;
}
static void headers_init(struct cal_control *ctl)