From: Matthew Wilcox <willy@infradead.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
Arnd Bergmann <arnd@arndb.de>, Jens Axboe <axboe@kernel.dk>,
Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
Hannes Reinecke <hare@suse.de>,
Bodo Stroesser <bstroesser@ts.fujitsu.com>,
Guoqing Jiang <guoqing.jiang@cloud.ionos.com>,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] target: pscsi: avoid Wempty-body warning
Date: Mon, 22 Mar 2021 16:06:31 +0000 [thread overview]
Message-ID: <20210322160631.GQ1719932@casper.infradead.org> (raw)
In-Reply-To: <20210322114441.3479365-1-arnd@kernel.org>
On Mon, Mar 22, 2021 at 12:44:34PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Building with 'make W=1' shows a harmless warning for pscsi:
>
> drivers/target/target_core_pscsi.c: In function 'pscsi_complete_cmd':
> drivers/target/target_core_pscsi.c:624:33: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 624 | ; /* XXX: TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE */
> | ^
>
> Rework the coding style as suggested by gcc to avoid the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/target/target_core_pscsi.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
> index 3cbc074992bc..913b092955f6 100644
> --- a/drivers/target/target_core_pscsi.c
> +++ b/drivers/target/target_core_pscsi.c
> @@ -620,8 +620,9 @@ static void pscsi_complete_cmd(struct se_cmd *cmd, u8 scsi_status,
> unsigned char *buf;
>
> buf = transport_kmap_data_sg(cmd);
> - if (!buf)
> - ; /* XXX: TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE */
> + if (!buf) {
> + /* XXX: TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE */
> + }
But why not just delete the code?
buf = transport_kmap_data_sg(cmd);
/* XXX: TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE */
I mean, this seems like a real warning here. We're not actually
handling the failure to allocate 'buf'. It's not marked as __must_check,
but watch the code flow:
buf = transport_kmap_data_sg(cmd);
if (!buf)
; /* XXX: TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE */
if (cdb[0] == MODE_SENSE_10) {
if (!(buf[3] & 0x80))
buf[3] |= 0x80;
} else {
if (!(buf[2] & 0x80))
buf[2] |= 0x80;
}
we're about to do a NULL ptr dereference. So this should be handled
somehow.
prev parent reply other threads:[~2021-03-22 16:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 11:44 [PATCH] target: pscsi: avoid Wempty-body warning Arnd Bergmann
2021-03-22 15:47 ` Christoph Hellwig
2021-03-22 15:53 ` Willy Tarreau
2021-03-22 16:18 ` Arnd Bergmann
2021-03-22 16:26 ` Willy Tarreau
2021-03-22 16:34 ` Arnd Bergmann
2021-03-22 16:38 ` Willy Tarreau
2021-03-23 17:24 ` David Laight
2021-03-22 16:06 ` Matthew Wilcox [this message]
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=20210322160631.GQ1719932@casper.infradead.org \
--to=willy@infradead.org \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=axboe@kernel.dk \
--cc=bstroesser@ts.fujitsu.com \
--cc=chaitanya.kulkarni@wdc.com \
--cc=guoqing.jiang@cloud.ionos.com \
--cc=hare@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).