mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Haberland <sth@linux.ibm.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Jan Hoeppner <hoeppner@linux.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: Re: [PATCH][next] s390/dasd: Use struct_size() helper
Date: Wed, 8 Jul 2020 11:13:08 +0200	[thread overview]
Message-ID: <47a86753-fd4d-9a7a-c808-5f387c872ab3@linux.ibm.com> (raw)
In-Reply-To: <20200619165600.GA8668@embeddedor>

Am 19.06.20 um 18:56 schrieb Gustavo A. R. Silva:
> Make use of the struct_size() helper instead of an open-coded version
> in order to avoid any potential type mistakes. Also, remove unnecessary
> variable _datasize_.
>
> This code was detected with the help of Coccinelle and, audited and
> fixed manually.
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks for the patch.
Tested and applied.

> ---
>  drivers/s390/block/dasd_diag.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
> index facb588d09e4..7f53ba015300 100644
> --- a/drivers/s390/block/dasd_diag.c
> +++ b/drivers/s390/block/dasd_diag.c
> @@ -506,7 +506,7 @@ static struct dasd_ccw_req *dasd_diag_build_cp(struct dasd_device *memdev,
>  	struct req_iterator iter;
>  	struct bio_vec bv;
>  	char *dst;
> -	unsigned int count, datasize;
> +	unsigned int count;
>  	sector_t recid, first_rec, last_rec;
>  	unsigned int blksize, off;
>  	unsigned char rw_cmd;
> @@ -534,10 +534,8 @@ static struct dasd_ccw_req *dasd_diag_build_cp(struct dasd_device *memdev,
>  	if (count != last_rec - first_rec + 1)
>  		return ERR_PTR(-EINVAL);
>  	/* Build the request */
> -	datasize = sizeof(struct dasd_diag_req) +
> -		count*sizeof(struct dasd_diag_bio);
> -	cqr = dasd_smalloc_request(DASD_DIAG_MAGIC, 0, datasize, memdev,
> -				   blk_mq_rq_to_pdu(req));
> +	cqr = dasd_smalloc_request(DASD_DIAG_MAGIC, 0, struct_size(dreq, bio, count),
> +				   memdev, blk_mq_rq_to_pdu(req));
>  	if (IS_ERR(cqr))
>  		return cqr;
>  


  reply	other threads:[~2020-07-08  9:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-19 16:56 Gustavo A. R. Silva
2020-07-08  9:13 ` Stefan Haberland [this message]
2020-07-08 19:39   ` Gustavo A. R. Silva

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=47a86753-fd4d-9a7a-c808-5f387c872ab3@linux.ibm.com \
    --to=sth@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hoeppner@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@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

all inboxes | Powered by JetHome®