Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751629AbbHBN6f (ORCPT ); Sun, 2 Aug 2015 09:58:35 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:55912 "EHLO mx2.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751375AbbHBN6e (ORCPT ); Sun, 2 Aug 2015 09:58:34 -0400 Date: Sun, 2 Aug 2015 15:48:45 +0200 From: Hagen Paul Pfeifer To: Tomer Barletz Cc: dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Avoid compiler warning by storing the result of rq_data_dir() in an int variable Message-ID: <20150802134845.GA31982@virgo.local> References: <1438511812-5270-1-git-send-email-barletz@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438511812-5270-1-git-send-email-barletz@gmail.com> X-Key-Id: 98350C22 X-Key-Fingerprint: 490F 557B 6C48 6D7E 5706 2EA2 4A22 8D45 9835 0C22 X-GPG-Key: gpg --recv-keys --keyserver wwwkeys.eu.pgp.net 98350C22 User-Agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1539 Lines: 56 * Tomer Barletz | 2015-08-02 03:36:52 [-0700]: >With gcc 5.1 I get: >warning: switch condition has boolean value [-Wswitch-bool] > >Signed-off-by: Tomer Barletz >--- > drivers/mtd/mtd_blkdevs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c >index 41acc50..8c3715c 100644 >--- a/drivers/mtd/mtd_blkdevs.c >+++ b/drivers/mtd/mtd_blkdevs.c >@@ -79,6 +79,7 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, > { > unsigned long block, nsect; > char *buf; >+ int rq; > > block = blk_rq_pos(req) << 9 >> tr->blkshift; > nsect = blk_rq_cur_bytes(req) >> tr->blkshift; >@@ -97,7 +98,8 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, > if (req->cmd_flags & REQ_DISCARD) > return tr->discard(dev, block, nsect); > >- switch(rq_data_dir(req)) { >+ rq = rq_data_dir(req); >+ switch(rq) { Gcc warning seems over the top here, but when then the coding guideline should be meet: switch (rw) { [..] On the other hand, rq_data_dir() *could* be simplified to: #define rq_data_dir(rq) (((rq)->cmd_flags & 1) Or just re-code the construct into a if else construct. if (rw == READ) { [...] } else { [...] } The default branch is superfluous anyway here. Hagen -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/