From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>
Subject: [PATCH 05/16] lslogins: reject unknown time format arguments
Date: Sun, 14 Dec 2014 17:44:01 +0000 [thread overview]
Message-ID: <1418579052-29386-6-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1418579052-29386-1-git-send-email-kerolasa@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
login-utils/lslogins.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index cacf83c..4b07636 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -1180,16 +1180,6 @@ static void free_user(void *f)
free(u);
}
-struct lslogins_timefmt {
- const char *name;
- int val;
-};
-
-static struct lslogins_timefmt timefmts[] = {
- { "short", TIME_SHORT },
- { "full", TIME_FULL },
- { "iso", TIME_ISO },
-};
static void __attribute__((__noreturn__)) usage(FILE *out)
{
@@ -1398,8 +1388,18 @@ int main(int argc, char *argv[])
break;
case OPT_TIME_FMT:
{
+ struct lslogins_timefmt {
+ const char *name;
+ const int val;
+ };
+ const struct lslogins_timefmt timefmts[] = {
+ { "iso", TIME_ISO },
+ { "full", TIME_FULL },
+ { "short", TIME_SHORT },
+ };
size_t i;
+ ctl->time_mode = TIME_INVALID;
for (i = 0; i < ARRAY_SIZE(timefmts); i++) {
if (strcmp(timefmts[i].name, optarg) == 0) {
ctl->time_mode = timefmts[i].val;
@@ -1407,7 +1407,7 @@ int main(int argc, char *argv[])
}
}
if (ctl->time_mode == TIME_INVALID)
- usage(stderr);
+ errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
}
break;
case 'V':
--
2.1.3
next prev parent reply other threads:[~2014-12-14 17:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-14 17:43 [PATCH 00/16] pull: updates to lslogins and chfn Sami Kerola
2014-12-14 17:43 ` [PATCH 01/16] lslogins: allow changing password changed and expiration time formats Sami Kerola
2014-12-14 17:43 ` [PATCH 02/16] lslogins: make journald last logs time stamps to honor --time-format Sami Kerola
2014-12-14 17:43 ` [PATCH 03/16] lslogins: tell why command failed Sami Kerola
2014-12-14 17:44 ` [PATCH 04/16] lslogins: fix short options Sami Kerola
2014-12-14 17:44 ` Sami Kerola [this message]
2014-12-15 9:28 ` [PATCH 05/16] lslogins: reject unknown time format arguments Karel Zak
2014-12-19 9:30 ` Sami Kerola
2014-12-14 17:44 ` [PATCH 06/16] lslogins: add space to systemd journal header and message Sami Kerola
2014-12-14 17:44 ` [PATCH 07/16] lslogins: use hardcoded paths from pathnames.h Sami Kerola
2014-12-14 17:44 ` [PATCH 08/16] chfn: remove function prototypes Sami Kerola
2014-12-14 17:44 ` [PATCH 09/16] chfn: rewrite prompt() to use strutils Sami Kerola
2014-12-14 17:44 ` [PATCH 10/16] chfn: use xasprintf() rather than bunch of strlen() and malloc() calls Sami Kerola
2014-12-14 17:44 ` [PATCH 11/16] chfn: fix usage() regression Sami Kerola
2014-12-14 17:44 ` [PATCH 12/16] chfn: simplify parse_passwd() by using strsep() Sami Kerola
2014-12-14 17:44 ` [PATCH 13/16] chfn: add minimalistic struct chfn_control Sami Kerola
2014-12-14 17:44 ` [PATCH 14/16] chfn: clean up parse_argv() Sami Kerola
2014-12-15 9:45 ` Karel Zak
2014-12-14 17:44 ` [PATCH 15/16] chfn: move new and old finger structs to chfn control struct Sami Kerola
2014-12-15 10:07 ` Karel Zak
2014-12-19 9:41 ` Sami Kerola
2014-12-14 17:44 ` [PATCH 16/16] chfn: make command to obey login.defs CHFN_RESTRICT instructions Sami Kerola
2014-12-15 10:11 ` Karel Zak
2014-12-19 13:30 ` [PATCH 00/16] pull: updates to lslogins and chfn Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418579052-29386-6-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).