Linux RAID subsystem development
 help / color / mirror / Atom feed
* [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"
@ 2017-03-30 16:58 Gioh Kim
  2017-03-30 17:50 ` Wols Lists
  2017-03-30 17:51 ` Jes Sorensen
  0 siblings, 2 replies; 3+ messages in thread
From: Gioh Kim @ 2017-03-30 16:58 UTC (permalink / raw)
  To: jes.sorensen, neilb; +Cc: linux-raid, linux-kernel, Gioh Kim

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>
---
 mdadm.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/mdadm.c b/mdadm.c
index 0f32773..d6b5437 100644
--- 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':
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"
  2017-03-30 16:58 [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value" Gioh Kim
@ 2017-03-30 17:50 ` Wols Lists
  2017-03-30 17:51 ` Jes Sorensen
  1 sibling, 0 replies; 3+ messages in thread
From: Wols Lists @ 2017-03-30 17:50 UTC (permalink / raw)
  To: Gioh Kim, jes.sorensen, neilb; +Cc: linux-raid, linux-kernel

You can add my acked-by (never done it before, not sure how :-)

Cheers,
Wol

On 30/03/17 17:58, Gioh Kim wrote:
> 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>
> ---
>  mdadm.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/mdadm.c b/mdadm.c
> index 0f32773..d6b5437 100644
> --- 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':
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"
  2017-03-30 16:58 [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value" Gioh Kim
  2017-03-30 17:50 ` Wols Lists
@ 2017-03-30 17:51 ` Jes Sorensen
  1 sibling, 0 replies; 3+ messages in thread
From: Jes Sorensen @ 2017-03-30 17:51 UTC (permalink / raw)
  To: Gioh Kim, neilb; +Cc: linux-raid, linux-kernel

On 03/30/2017 12:58 PM, Gioh Kim wrote:
> 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>
> ---
>  mdadm.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)

Applied!

Thanks,
Jes

> diff --git a/mdadm.c b/mdadm.c
> index 0f32773..d6b5437 100644
> --- 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':
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-30 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-30 16:58 [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value" Gioh Kim
2017-03-30 17:50 ` Wols Lists
2017-03-30 17:51 ` Jes Sorensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox