]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm.c: fix compile error "switch condition has boolean value"
authorGioh Kim <gi-oh.kim@profitbricks.com>
Thu, 30 Mar 2017 16:58:13 +0000 (18:58 +0200)
committerJes Sorensen <Jes.Sorensen@gmail.com>
Thu, 30 Mar 2017 17:46:14 +0000 (13:46 -0400)
Remove a boolean expression in switch condition
to prevent compile error of some compilers,
for example, gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2).

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
mdadm.c

diff --git a/mdadm.c b/mdadm.c
index 0f3277382637df5c940242be6861d67234b3b274..d6b54378a6bed8a5d4748c1299246b3a77af9d37 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1965,14 +1965,12 @@ static int misc_list(struct mddev_dev *devlist,
                        rv |= SetAction(dv->devname, c->action);
                        continue;
                }
-               switch(dv->devname[0] == '/') {
-                       case 0:
-                               mdfd = open_dev(dv->devname);
-                               if (mdfd >= 0)
-                                       break;
-                       case 1:
-                               mdfd = open_mddev(dv->devname, 1);  
-               }
+
+               if (dv->devname[0] != '/')
+                       mdfd = open_dev(dv->devname);
+               if (dv->devname[0] == '/' || mdfd < 0)
+                       mdfd = open_mddev(dv->devname, 1);
+
                if (mdfd >= 0) {
                        switch(dv->disposition) {
                        case 'R':