]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: Rearrange option parsing for KillSubarray and UpdateSubarray
authorJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 2 Nov 2011 21:06:47 +0000 (08:06 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 2 Nov 2011 21:06:47 +0000 (08:06 +1100)
Extracting the 'subarray' arg for these options was being done at the
wrong place which lead to the code being a bit confusing and looking
wrong.

So reformat that code a bit better and move the extraction of
'subarray' down to the main parsing of these options rather than the
mode setting.

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.c

diff --git a/mdadm.c b/mdadm.c
index 56de7b7e8df4cd75cd5a2dfd6368317663b02221..8e0ce18656d496a80a049475efbbf900dacdbf58 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -212,13 +212,17 @@ int main(int argc, char *argv[])
                case 'I': newmode = INCREMENTAL;
                        shortopt = short_bitmap_auto_options; break;
                case AutoDetect:
-                       newmode = AUTODETECT; break;
+                       newmode = AUTODETECT;
+                       break;
 
                case MiscOpt:
                case 'D':
                case 'E':
                case 'X':
-               case 'Q': newmode = MISC; break;
+               case 'Q':
+                       newmode = MISC;
+                       break;
+
                case 'R':
                case 'S':
                case 'o':
@@ -229,17 +233,15 @@ int main(int argc, char *argv[])
                case DetailPlatform:
                case KillSubarray:
                case UpdateSubarray:
-                       if (opt == KillSubarray || opt == UpdateSubarray) {
-                               if (subarray) {
-                                       fprintf(stderr, Name ": subarray can only"
-                                               " be specified once\n");
-                                       exit(2);
-                               }
-                               subarray = optarg;
-                       }
                case UdevRules:
-               case 'K': if (!mode) newmode = MISC; break;
-               case NoSharing: newmode = MONITOR; break;
+               case 'K':
+                       if (!mode)
+                               newmode = MISC;
+                       break;
+
+               case NoSharing:
+                       newmode = MONITOR;
+                       break;
                }
                if (mode && newmode == mode) {
                        /* everybody happy ! */
@@ -924,6 +926,14 @@ int main(int argc, char *argv[])
                case O(MISC, DetailPlatform):
                case O(MISC, KillSubarray):
                case O(MISC, UpdateSubarray):
+                       if (opt == KillSubarray || opt == UpdateSubarray) {
+                               if (subarray) {
+                                       fprintf(stderr, Name ": subarray can only"
+                                               " be specified once\n");
+                                       exit(2);
+                               }
+                               subarray = optarg;
+                       }
                        if (devmode && devmode != opt &&
                            (devmode == 'E' || (opt == 'E' && devmode != 'Q'))) {
                                fprintf(stderr, Name ": --examine/-E cannot be given with ");