All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hagen Paul Pfeifer <hagen@jauu.net>
To: Tomer Barletz <barletz@gmail.com>
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
Date: Sun, 2 Aug 2015 15:48:45 +0200	[thread overview]
Message-ID: <20150802134845.GA31982@virgo.local> (raw)
In-Reply-To: <1438511812-5270-1-git-send-email-barletz@gmail.com>

* 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 <barletz@gmail.com>
>---
> 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

  reply	other threads:[~2015-08-02 13:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-02 10:36 [PATCH] Avoid compiler warning by storing the result of rq_data_dir() in an int variable Tomer Barletz
2015-08-02 13:48 ` Hagen Paul Pfeifer [this message]
2015-08-03  5:49   ` Tomer Barletz
2015-08-05  4:00   ` [PATCH] mtd: Fix switch-bool compilation warning Tomer Barletz
2015-08-25 20:59     ` Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150802134845.GA31982@virgo.local \
    --to=hagen@jauu.net \
    --cc=barletz@gmail.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.