]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Assemble: merge to large 'if' statements.
authorNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)
In assemble, we see (inside a 'for' loop):

 if (condition) {
    lots of stuff
 } else
    something

 small thing

 if (same condition) {
     lots more stuff
     break;
 }

where 'condition' cannot be changed in the middle.

So simplify this to

 if (condition) {
    lots of stuff
    small thing
    lots more stuff
    break;
 }

 something
 small thing

which duplicates the small thing, but provides much
conceptual simplicity.

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

index 6ba78a8669c5919177514279397cdb29b4804dad..197ae1ea2f5a8a912f3a47160823d4882b7899f5 100644 (file)
@@ -402,22 +402,11 @@ int Assemble(struct supertype *st, char *mddev,
                        if (tmpdev->content == NULL)
                                tmpdev->used = 2;
 
-               } else if (ident->container || ident->member) {
-                       /* No chance of this matching if we don't have
-                        * a container */
-                       if (report_missmatch)
-                               fprintf(stderr, Name "%s is not a container, and one is required.\n",
-                                       devname);
-                       goto loop;
-               }
-
-               if (!ident_matches(ident, content, tst,
-                                  homehost, update,
-                                  report_missmatch ? devname : NULL))
-                       goto loop;
+                       if (!ident_matches(ident, content, tst,
+                                          homehost, update,
+                                          report_missmatch ? devname : NULL))
+                               goto loop;
 
-               if (tst->ss->container_content
-                   && tst->loaded_container) {
                        /* we have the one container we need, don't keep
                         * looking.  If the chosen member is active, skip.
                         */
@@ -466,6 +455,21 @@ int Assemble(struct supertype *st, char *mddev,
                                        content->text_version, devname);
                        break;
                }
+
+               if (ident->container || ident->member) {
+                       /* No chance of this matching if we don't have
+                        * a container */
+                       if (report_missmatch)
+                               fprintf(stderr, Name "%s is not a container, and one is required.\n",
+                                       devname);
+                       goto loop;
+               }
+
+               if (!ident_matches(ident, content, tst,
+                                  homehost, update,
+                                  report_missmatch ? devname : NULL))
+                       goto loop;
+
                if (st == NULL)
                        st = dup_super(tst);
                if (st->minor_version == -1)