Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1613294 > unrolled thread

[PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"

Started byGioh Kim <gi-oh.kim@profitbricks.com>
First post2017-03-30 19:00 +0200
Last post2017-03-30 20:00 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value" Gioh Kim <gi-oh.kim@profitbricks.com> - 2017-03-30 19:00 +0200
    Re: [PATCHv2] mdadm.c: fix compile error "switch condition has  boolean value" Wols Lists <antlists@youngman.org.uk> - 2017-03-30 20:00 +0200
    Re: [PATCHv2] mdadm.c: fix compile error "switch condition has  boolean value" Jes Sorensen <jes.sorensen@gmail.com> - 2017-03-30 20:00 +0200

#1613294 — [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"

FromGioh Kim <gi-oh.kim@profitbricks.com>
Date2017-03-30 19:00 +0200
Subject[PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"
Message-ID<tqLAu-O7-9@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1613331 — Re: [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"

FromWols Lists <antlists@youngman.org.uk>
Date2017-03-30 20:00 +0200
SubjectRe: [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"
Message-ID<tqMwx-1vj-3@gated-at.bofh.it>
In reply to#1613294
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':
> 

[toc] | [prev] | [next] | [standalone]


#1613337 — Re: [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"

FromJes Sorensen <jes.sorensen@gmail.com>
Date2017-03-30 20:00 +0200
SubjectRe: [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value"
Message-ID<tqMwy-1vj-23@gated-at.bofh.it>
In reply to#1613294
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':
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web