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 <neilb@suse.de>
This commit is contained in:
parent
96ae5973dd
commit
5a53aeec7f
34
mdadm.c
34
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 ");
|
||||
|
|
Loading…
Reference in New Issue