Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2267792ybi; Mon, 1 Jul 2019 09:03:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2cAJTTgNy/xpdJg6twUEhdLN58RTNYDI71K9cUGAoolEQTZA9RAoVtfuRh65iDdpMfw0b X-Received: by 2002:a63:1310:: with SMTP id i16mr6653359pgl.187.1561997014763; Mon, 01 Jul 2019 09:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561997014; cv=none; d=google.com; s=arc-20160816; b=Bze4ioP8v9OVQTyTkRIjFby1g8HY4tPLfjIG/LoALEUdcnXi+jPCo0aQaSMFZKIP+A 7yFRUtXpB9Ya/0CqGyz+xVZZMs4hIdjwR6+sQAeJqJio3YNlgTWICdJ1VE2Xi2ZqvKte E94MIzqWrBHBamyr+S+Pn7y8OB0hPu0WQkt/qW7tfcffxUjElRIuVONERJ2SU64dDLjU dTkslg8dnTeXYHDrxJuJo5zVCTjUAL7Y4XWkdVYuM+EZnu/qMxpPdxNXmOOcJnVz0kby E3Qq5clgZrNiZ7tl7xTDnaAKP/iqjWlPIF3kgG6n++HlN/gyIf0y403W8ALg/arkBK4l 8r/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=timzreh4zf8pDErjBjtEbdJaEMPFqHbxH3SIoZzjVAI=; b=xiWQneT2zP1zmaUSUZDxHtltjk6/nOYO24cBzWNkZNVcjGkYhFYhnVVkRplejp7gWh jlnvuqoLNizWjaeG6SNLoC2f9IP10jhc0Edf1vbVeI5frZWWmsZ+/S3Jhe1KowjhHbcf ax65m0F46I7WzGjqfv0QjHotMFD+602YVxIOITlXsfXpnqGx9mU6CTQ80vzzq38vTZl4 bZy0dRcz/dvWeEzFlKlW+zSWPCRrtPGr7Ac1sOXnt3Td0WIH/zIRZjSDa2z3PPYdC8Vf 3QIBOPsz48EHMqugDj6SpwWaEGeFiGhsY52R7EZKf2PcCo83YE8AIDXNMKR5E/9HQgY0 q13w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33si10401973pgi.89.2019.07.01.09.03.16; Mon, 01 Jul 2019 09:03:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbfGAPWH (ORCPT + 99 others); Mon, 1 Jul 2019 11:22:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33292 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbfGAPWH (ORCPT ); Mon, 1 Jul 2019 11:22:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C19483082A9A; Mon, 1 Jul 2019 15:21:54 +0000 (UTC) Received: from localhost (unknown [10.36.118.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 268386F947; Mon, 1 Jul 2019 15:21:49 +0000 (UTC) Date: Mon, 1 Jul 2019 16:21:48 +0100 From: Stefan Hajnoczi To: "Gustavo A. R. Silva" Cc: "Michael S. Tsirkin" , Jason Wang , Paolo Bonzini , "James E.J. Bottomley" , "Martin K. Petersen" , virtualization@lists.linux-foundation.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] scsi: virtio_scsi: Use struct_size() helper Message-ID: <20190701152148.GG11900@stefanha-x1.localdomain> References: <20190619192833.GA825@embeddedor> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+sHJum3is6Tsg7/J" Content-Disposition: inline In-Reply-To: <20190619192833.GA825@embeddedor> User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 01 Jul 2019 15:22:07 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --+sHJum3is6Tsg7/J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 19, 2019 at 02:28:33PM -0500, Gustavo A. R. Silva wrote: > One of the more common cases of allocation size calculations is finding > the size of a structure that has a zero-sized array at the end, along > with memory for some number of elements for that array. For example: >=20 > struct virtio_scsi { > ... > struct virtio_scsi_vq req_vqs[]; > }; >=20 > Make use of the struct_size() helper instead of an open-coded version > in order to avoid any potential type mistakes. >=20 > So, replace the following form: >=20 > sizeof(*vscsi) + sizeof(vscsi->req_vqs[0]) * num_queues >=20 > with: >=20 > struct_size(vscsi, req_vqs, num_queues) >=20 > This code was detected with the help of Coccinelle. >=20 > Signed-off-by: Gustavo A. R. Silva > --- > drivers/scsi/virtio_scsi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Stefan Hajnoczi --+sHJum3is6Tsg7/J Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAl0aJQwACgkQnKSrs4Gr c8hU0wf/SEM8YCmD62jJAJNbhuuxbgPPdSmJV/Oh3RzqiM/ujaeDjX1Msi+8fFbR NlE7Cr9xEkGuEacjWbl+MNio761nAUo5Ibln9uws3BTpnHClVohmaat2RfuRyoB5 0O1FC55L1Gj8+/RaRoZAO3gld6TM5+KFuptuYN4kOl9/DJDSbjoGX11dFtyL6Jut mSdjs07Koh+Uxt+2/gIEoflBy6tr8nbOIpIb0qI9Y+4iYXUFPvRqDhqnZ1TezcWE T4lWINqg4FuT+MMmCAyk8KLhj9FVKLMG7mCRT/R+emhi2yTwyMwvKLYeMW0uikUQ 2NfsNT8OZBYFNEdUzjeCiw4Mg8f99A== =FseJ -----END PGP SIGNATURE----- --+sHJum3is6Tsg7/J--