Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1000503ybt; Fri, 19 Jun 2020 21:09:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEKW/U9+/0rAWWeQbguB6goTsPARe35u/lJUn+0enrFkQAkVwq43g2D4p87nZkEuXilVBG X-Received: by 2002:aa7:c81a:: with SMTP id a26mr6724535edt.353.1592626196034; Fri, 19 Jun 2020 21:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592626196; cv=none; d=google.com; s=arc-20160816; b=MC9Dj1OvKDWN1Xd9sADmnTg+25RZCa8c/kss/Pn4t4sFl1nH1ZGO/1pCGxG2tY7enr Fay0w+eGTmOEgozRukEjIFzHnJUE+NvPdGize8QOSYo5ordzV+VrmurZhuoSueZjp1F8 Zq/JCu4T6cjFqID020EuJFYxeJ2VxAbfVNLtT4LayZR1n0QvJ1anbEDE8OHyQOVsn9yl hl8Zx+FEuIQ+ni/NwCgW/JKZ+yvUI5ZsOF50Gs0vmpS8hrQEfg1vGK1Sm3MA0ZC5ps81 vYPC9kE5jcy7xITrLq7zqpcuAIIPTejmrTPQnFrqwEYywtX8JGwubDa09Zo9dNdzDrXu xExQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=ZeReueoOSGjlTgL4T5xbCH0OPeiAGQnNfeNfYOwogqg=; b=PGM4GivZYohImekppM8FtRTeeVzMqTiD0CI2TqezUnZz8AA/ypyQOcQ08CyCrQ7fLI aBH5HJ8SWYapq4g6o0n1i4Uho9CTKTnk9u3Sx906BWl5j3IuU7B9B6CClzWvOCPuQT9B f+jHeOJt9PCJQH37ezSPPjXTI/2XBBBEbWokrFcvn3gePzohYyjwj2T3KAar7UudLjsh /Z0f+tYJQr7GL886vRNAt2FwR9ns6vyS42r2xLGSwcw1z1hQPDa6utBzpvleowMmpCxT HaQ40hmzbBsplMptB1zc5xU1kp2EDxbGxpDya4wKLASS9rk9FAoDzFZzXGyUFBAN8bhM 6JTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dWv0u1B2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si5251689edt.28.2020.06.19.21.09.34; Fri, 19 Jun 2020 21:09:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dWv0u1B2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405850AbgFSQuj (ORCPT + 99 others); Fri, 19 Jun 2020 12:50:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:34124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405838AbgFSQuh (ORCPT ); Fri, 19 Jun 2020 12:50:37 -0400 Received: from embeddedor (unknown [189.207.59.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF4A4206B7; Fri, 19 Jun 2020 16:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592585436; bh=8fLK+Pjpfcxokj4e/RXkF66iJ9dZAUaLX/pDyeawXhY=; h=Date:From:To:Cc:Subject:From; b=dWv0u1B2cwrZIR6QXdF5eKMnncRQydszuekOIZHLQYR2hOkxkIpgCLEgZfX8XmE9F WaDNZiSrro7iqsDKv3ysZsAfltZdriad2K9OErAKFzA0wr3L6wO5Ao43NipY/r+K6b 3tofXaI5FmD7bbvEJ0RadaTTryL23qWpFml02x2s= Date: Fri, 19 Jun 2020 11:56:00 -0500 From: "Gustavo A. R. Silva" To: Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Christian Borntraeger Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH][next] s390/dasd: Use struct_size() helper Message-ID: <20200619165600.GA8668@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.27.0