lkml.org 
[lkml]   [2017]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/2] mdadm.c: fix compile error "switch condition has boolean value"
On Thu, Mar 30 2017, jes.sorensen@gmail.com wrote:

> Gioh Kim <gi-oh.kim@profitbricks.com> writes:
>> Remove a boolean expression in switch condition
>> to prevent compile error of some compilers.
>
> Please be specific, which compile is unable to handle this?
>
>> Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
>> ---
>> mdadm.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/mdadm.c b/mdadm.c
>> index 08ddcab..a98a051 100644
>> --- a/mdadm.c
>> +++ b/mdadm.c
>> @@ -1905,11 +1905,11 @@ static int misc_list(struct mddev_dev *devlist,
>> rv |= SetAction(dv->devname, c->action);
>> continue;
>> }
>> - switch(dv->devname[0] == '/') {
>> - case 0:
>> + switch(dv->devname[0]) {
>> + default:
>> mdfd = open_dev(dv->devname);
>> if (mdfd >= 0) break;
>> - case 1:
>> + case '/':
>> mdfd = open_mddev(dv->devname, 1);
>> }
>> if (mdfd>=0) {
>
> While I agree the original code is ugly, I am not convinced your
> replacement is a lot prettier.
>

Maybe

if (dv->devname[0] == '/' ||
(mdfd = open_dev(dv->devname)) < 0)
mdfd = open_mddev(dv->devname, 1);

??
NeilBrown
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2017-03-29 23:40    [W:0.089 / U:0.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site