]> granicus.if.org Git - shadow/commitdiff
* src/chpasswd.c: Add annotations to indicate that usage() does
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 23 Jul 2011 08:14:15 +0000 (08:14 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 23 Jul 2011 08:14:15 +0000 (08:14 +0000)
not return.
* src/chpasswd.c: Reindent.
* src/chpasswd.c: Remove dead code. No need to set crypt_method
to NULL when it is already NULL. sflg is only set if crypt_method
is not NULL.

ChangeLog
src/chpasswd.c

index ee16134c30a480b6bb4ee556fdf3c2d9b00f9da2..d73f8930f14ad40d73d61284fd3d1241e0ebbfb3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-23  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/chpasswd.c: Add annotations to indicate that usage() does
+       not return.
+       * src/chpasswd.c: Reindent.
+       * src/chpasswd.c: Remove dead code. No need to set crypt_method
+       to NULL when it is already NULL. sflg is only set if crypt_method
+       is not NULL.
+
 2011-07-23  Nicolas François  <nicolas.francois@centraliens.net>
 
        * src/lastlog.c: Add annotations to indicate that usage() does not
index 374155065971b6a1707dd7b88f1ba1384dca3c12..52571a4570934c9b8fb7befcf6817d3f5f3b73fa 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1990 - 1994, Julianne Frances Haugh
  * Copyright (c) 1996 - 2000, Marek Michałkiewicz
  * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2009, Nicolas François
+ * Copyright (c) 2007 - 2011, Nicolas François
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -72,7 +72,7 @@ static bool spw_locked = false;
 
 /* local function prototypes */
 static void fail_exit (int code);
-static void usage (int status);
+static /*@noreturn@*/void usage (int status);
 static void process_flags (int argc, char **argv);
 static void check_flags (void);
 static void check_perms (void);
@@ -106,7 +106,7 @@ static void fail_exit (int code)
 /*
  * usage - display usage message and exit
  */
-static void usage (int status)
+static /*@noreturn@*/void usage (int status)
 {
        FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
        (void) fprintf (usageout,
@@ -167,7 +167,7 @@ static void process_flags (int argc, char **argv)
                switch (c) {
                case 'h':
                        usage (E_SUCCESS);
-                       break;
+                       /*@notreached@*/break;
                case 'c':
                        cflg = true;
                        crypt_method = optarg;
@@ -191,7 +191,7 @@ static void process_flags (int argc, char **argv)
 #endif                         /* USE_SHA_CRYPT */
                default:
                        usage (E_USAGE);
-                       break;
+                       /*@notreached@*/break;
                }
        }
 
@@ -456,12 +456,12 @@ int main (int argc, char **argv)
 
 #ifdef USE_PAM
                if (use_pam){
-               if (do_pam_passwd_non_interractive ("chpasswd", name, newpwd) != 0) {
-                       fprintf (stderr,
-                                _("%s: (line %d, user %s) password not changed\n"),
-                                Prog, line, name);
-                       errors++;
-               }
+                       if (do_pam_passwd_non_interractive ("chpasswd", name, newpwd) != 0) {
+                               fprintf (stderr,
+                                        _("%s: (line %d, user %s) password not changed\n"),
+                                        Prog, line, name);
+                               errors++;
+                       }
                } else
 #endif                         /* USE_PAM */
                {
@@ -476,15 +476,12 @@ int main (int argc, char **argv)
                        void *arg = NULL;
                        if (md5flg) {
                                crypt_method = "MD5";
-                       } else if (crypt_method != NULL) {
+                       }
 #ifdef USE_SHA_CRYPT
-                               if (sflg) {
-                                       arg = &sha_rounds;
-                               }
-#endif
-                       } else {
-                               crypt_method = NULL;
+                       if (sflg) {
+                               arg = &sha_rounds;
                        }
+#endif
                        cp = pw_encrypt (newpwd,
                                         crypt_make_salt(crypt_method, arg));
                }