Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934363AbdC3Rvc (ORCPT ); Thu, 30 Mar 2017 13:51:32 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:35298 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933375AbdC3Rva (ORCPT ); Thu, 30 Mar 2017 13:51:30 -0400 From: Jes Sorensen X-Google-Original-From: Jes Sorensen Subject: Re: [PATCHv2] mdadm.c: fix compile error "switch condition has boolean value" To: Gioh Kim , neilb@suse.com References: <1490893093-4666-1-git-send-email-gi-oh.kim@profitbricks.com> Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: Date: Thu, 30 Mar 2017 13:51:26 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1490893093-4666-1-git-send-email-gi-oh.kim@profitbricks.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1035 Lines: 41 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 > --- > 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': >