]> granicus.if.org Git - shadow/commitdiff
* src/faillog.c: Add annotations to indicate that usage() does not
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 22 Jul 2011 23:59:57 +0000 (23:59 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 22 Jul 2011 23:59:57 +0000 (23:59 +0000)
return.
* src/faillog.c: Fix message: this is faillog, not lastlog.
* src/faillog.c: Check that there are no extra arguments after
parsing the options.

ChangeLog
src/faillog.c

index a0a7234b8daf8df0746fa0dc60093b8392a80e46..8cae8a14e9ff48df3928d0ce047bbfda7e8f0a2d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-07-23  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/faillog.c: Add annotations to indicate that usage() does not
+       return.
+       * src/faillog.c: Fix message: this is faillog, not lastlog.
+       * src/faillog.c: Check that there are no extra arguments after
+       parsing the options.
+
 2011-07-23  Nicolas François  <nicolas.francois@centraliens.net>
 
        * src/chgpasswd.c: Add annotations to indicate that usage() does
index 2742f2ee9d7f19accaa96edff6c9cdf6285e5f64..7d3aa62ec7a6be41fdd882b9130316d7c9d8674b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1989 - 1993, Julianne Frances Haugh
  * Copyright (c) 1996 - 2000, Marek Michałkiewicz
  * Copyright (c) 2002 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2010, Nicolas François
+ * Copyright (c) 2007 - 2011, Nicolas François
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -48,7 +48,7 @@
 #include "exitcodes.h"
 
 /* local function prototypes */
-static void usage (int status);
+static /*@noreturn@*/void usage (int status);
 static void print_one (/*@null@*/const struct passwd *pw, bool force);
 static void set_locktime (long locktime);
 static bool set_locktime_one (uid_t uid, long locktime);
@@ -80,7 +80,7 @@ static struct stat statbuf;   /* fstat buffer for file size */
 
 #define        NOW     (time((time_t *) 0))
 
-static void usage (int status)
+static /*@noreturn@*/void usage (int status)
 {
        FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
        (void) fprintf (usageout,
@@ -587,7 +587,7 @@ int main (int argc, char **argv)
                                break;
                        case 'h':
                                usage (E_SUCCESS);
-                               break;
+                               /*@notreached@*/break;
                        case 'l':
                                if (getlong (optarg, &fail_locktime) == 0) {
                                        fprintf (stderr,
@@ -643,7 +643,7 @@ int main (int argc, char **argv)
                                                      &umin, &has_umin,
                                                      &umax, &has_umax) == 0) {
                                                fprintf (stderr,
-                                                        _("lastlog: Unknown user or range: %s\n"),
+                                                        _("faillog: Unknown user or range: %s\n"),
                                                         optarg);
                                                exit (E_BAD_ARG);
                                        }
@@ -655,6 +655,12 @@ int main (int argc, char **argv)
                                usage (E_USAGE);
                        }
                }
+               if (argc > optind) {
+                       fprintf (stderr,
+                                _("faillog: unexpected argument: %s\n"),
+                                argv[optind]);
+                       usage (EXIT_FAILURE);
+               }
        }
 
        if (tflg && (lflg || mflg || rflg)) {