]> granicus.if.org Git - shadow/commitdiff
New function check_flags(). Split the validation of
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 28 Dec 2007 21:04:04 +0000 (21:04 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 28 Dec 2007 21:04:04 +0000 (21:04 +0000)
options and arguments out of process_flags.

ChangeLog
src/groupadd.c

index 912df94c4d8cbabb87b5ff893c8caefc3cc4cb20..191ed849f76d3b5951d686370929c064210a4a1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,8 @@
        * src/groupadd.c: Avoid implicit brackets.
        * src/groupadd.c: Split the processing and checking of options out of
        main() (process_flags).
+       * src/groupadd.c: New function check_flags(). Split the validation of
+       options and arguments out of process_flags.
        * src/groupadd.c: Add the parameters' names in the prototypes.
 
 2007-12-27  Nicolas François  <nicolas.francois@centraliens.net>
index d28a22b9c05b1534e2ffe8c92ef1ef6def7671aa..fddba80f118c2dcf95de891f26d8e54fa6e567a7 100644 (file)
@@ -91,6 +91,7 @@ static void open_files (void);
 static void fail_exit (int code);
 static gid_t get_gid (const char *gidstr);
 static void process_flags (int argc, char **argv);
+static void check_flags (void);
 static void check_perms (void);
 
 /*
@@ -434,16 +435,21 @@ static void process_flags (int argc, char **argv)
        /*
         * Check the flags consistency
         */
-       if (oflg && !gflg) {
+       if (optind != argc - 1) {
                usage ();
        }
+       group_name = argv[optind];
 
-       if (optind != argc - 1) {
+       check_flags ();
+}
+
+static void check_flags (void)
+{
+       /* -o does not make sense without -g */
+       if (oflg && !gflg) {
                usage ();
        }
 
-       group_name = argv[optind];
-
        check_new_name ();
 
        /*