From 5a53aeec7f333e22682930d8fe228b572b7f55c9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Thu, 3 Nov 2011 08:06:47 +1100 Subject: [PATCH] mdadm: Rearrange option parsing for KillSubarray and UpdateSubarray 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 --- mdadm.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/mdadm.c b/mdadm.c index 56de7b7e..8e0ce186 100644 --- 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 "); -- 2.47.2