Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/user The "default" case usually occurs at the end o...



details:   https://anonhg.NetBSD.org/src/rev/16a9726b954c
branches:  trunk
changeset: 545689:16a9726b954c
user:      agc <agc%NetBSD.org@localhost>
date:      Mon Apr 14 17:40:07 2003 +0000

description:
The "default" case usually occurs at the end of all other options, so change
it to follow convention.

Add /* NOTREACHED */ comments, per share/misc/style.

diffstat:

 usr.sbin/user/user.c |  44 ++++++++++++++++++++++++++------------------
 1 files changed, 26 insertions(+), 18 deletions(-)

diffs (166 lines):

diff -r 26c5ca12c26b -r 16a9726b954c usr.sbin/user/user.c
--- a/usr.sbin/user/user.c      Mon Apr 14 16:18:23 2003 +0000
+++ b/usr.sbin/user/user.c      Mon Apr 14 17:40:07 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.68 2003/04/14 09:49:15 dsl Exp $ */
+/* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */
 
 /*
  * Copyright (c) 1999 Alistair G. Crooks.  All rights reserved.
@@ -35,7 +35,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999 \
                The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: user.c,v 1.68 2003/04/14 09:49:15 dsl Exp $");
+__RCSID("$NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1558,8 +1558,6 @@
        defaultfield = bigD = 0;
        while ((c = getopt(argc, argv, "DG:b:c:d:e:f:g:k:mou:s:" ADD_OPT_EXTENSIONS)) != -1) {
                switch(c) {
-               default:
-                       usermgmt_usage("useradd");
                case 'D':
                        bigD = 1;
                        break;
@@ -1639,6 +1637,9 @@
                        verbose = 1;
                        break;
 #endif
+               default:
+                       usermgmt_usage("useradd");
+                       /* NOTREACHED */
                }
        }
        if (bigD) {
@@ -1691,8 +1692,6 @@
        have_new_user = 0;
        while ((c = getopt(argc, argv, "G:c:d:e:f:g:l:mos:u:" MOD_OPT_EXTENSIONS)) != -1) {
                switch(c) {
-               default:
-                       usermgmt_usage("usermod");
                case 'G':
                        while ((u.u_groupv[u.u_groupc] = strsep(&optarg, ",")) != NULL &&
                               u.u_groupc < NGROUPS_MAX) {
@@ -1764,6 +1763,9 @@
                        verbose = 1;
                        break;
 #endif
+               default:
+                       usermgmt_usage("usermod");
+                       /* NOTREACHED */
                }
        }
        if ((u.u_flags & F_MKDIR) && !(u.u_flags & F_HOMEDIR) &&
@@ -1803,8 +1805,6 @@
        defaultfield = bigD = rmhome = 0;
        while ((c = getopt(argc, argv, "r" DEL_OPT_EXTENSIONS)) != -1) {
                switch(c) {
-               default:
-                       usermgmt_usage("userdel");
 #ifdef EXTENSIONS
                case 'D':
                        bigD = 1;
@@ -1826,6 +1826,9 @@
                        verbose = 1;
                        break;
 #endif
+               default:
+                       usermgmt_usage("userdel");
+                       /* NOTREACHED */
                }
        }
 #ifdef EXTENSIONS
@@ -1885,8 +1888,6 @@
        dupgid = 0;
        while ((c = getopt(argc, argv, "g:o" GROUP_ADD_OPT_EXTENSIONS)) != -1) {
                switch(c) {
-               default:
-                       usermgmt_usage("groupadd");
                case 'g':
                        if (!is_number(optarg)) {
                                errx(EXIT_FAILURE, "When using [-g gid], the gid must be numeric");
@@ -1901,6 +1902,9 @@
                        verbose = 1;
                        break;
 #endif
+               default:
+                       usermgmt_usage("groupadd");
+                       /* NOTREACHED */
                }
        }
        argc -= optind;
@@ -1939,13 +1943,14 @@
 
        while ((c = getopt(argc, argv, "" GROUP_DEL_OPT_EXTENSIONS)) != -1) {
                switch(c) {
-               default:
-                       usermgmt_usage("groupdel");
 #ifdef EXTENSIONS
                case 'v':
                        verbose = 1;
                        break;
 #endif
+               default:
+                       usermgmt_usage("groupdel");
+                       /* NOTREACHED */
                }
        }
        argc -= optind;
@@ -1985,8 +1990,6 @@
        newname = NULL;
        while ((c = getopt(argc, argv, "g:on:" GROUP_MOD_OPT_EXTENSIONS)) != -1) {
                switch(c) {
-               default:
-                       usermgmt_usage("groupmod");
                case 'g':
                        if (!is_number(optarg)) {
                                errx(EXIT_FAILURE, "When using [-g gid], the gid must be numeric");
@@ -2004,6 +2007,9 @@
                        verbose = 1;
                        break;
 #endif
+               default:
+                       usermgmt_usage("groupmod");
+                       /* NOTREACHED */
                }
        }
        argc -= optind;
@@ -2059,14 +2065,15 @@
        exists = 0;
        while ((i = getopt(argc, argv, "ev")) != -1) {
                switch(i) {
-               default:
-                       usermgmt_usage("userinfo");
                case 'e':
                        exists = 1;
                        break;
                case 'v':
                        verbose = 1;
                        break;
+               default:
+                       usermgmt_usage("userinfo");
+                       /* NOTREACHED */
                }
        }
        argc -= optind;
@@ -2121,14 +2128,15 @@
        exists = 0;
        while ((i = getopt(argc, argv, "ev")) != -1) {
                switch(i) {
-               default:
-                       usermgmt_usage("groupinfo");
                case 'e':
                        exists = 1;
                        break;
                case 'v':
                        verbose = 1;
                        break;
+               default:
+                       usermgmt_usage("groupinfo");
+                       /* NOTREACHED */
                }
        }
        argc -= optind;



Home | Main Index | Thread Index | Old Index