[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171004121449.kywykfgyxtkmu2ar@linux.intel.com>
Date: Wed, 4 Oct 2017 15:14:49 +0300
From: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
To: Jérémy Lefaure <jeremy.lefaure@....epita.fr>
Cc: Peter Huewe <peterhuewe@....de>,
Jason Gunthorpe <jgunthorpe@...idianresearch.com>,
linux-integrity@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 13/18] tpm: use ARRAY_SIZE
On Sun, Oct 01, 2017 at 03:30:51PM -0400, Jérémy Lefaure wrote:
> Using the ARRAY_SIZE macro improves the readability of the code.
>
> Found with Coccinelle with the following semantic patch:
> @r depends on (org || report)@
> type T;
> T[] E;
> position p;
> @@
> (
> (sizeof(E)@p /sizeof(*E))
> |
> (sizeof(E)@p /sizeof(E[...]))
> |
> (sizeof(E)@p /sizeof(T))
> )
>
> Signed-off-by: Jérémy Lefaure <jeremy.lefaure@....epita.fr>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
/Jarkko
> ---
> drivers/char/tpm/tpm_tis.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index ebd0e75a3e4d..e2d1055fb814 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -30,6 +30,7 @@
> #include <linux/freezer.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> +#include <linux/kernel.h>
> #include "tpm.h"
> #include "tpm_tis_core.h"
>
> @@ -365,7 +366,7 @@ static struct pnp_driver tis_pnp_driver = {
> },
> };
>
> -#define TIS_HID_USR_IDX sizeof(tpm_pnp_tbl)/sizeof(struct pnp_device_id) -2
> +#define TIS_HID_USR_IDX (ARRAY_SIZE(tpm_pnp_tbl) - 2)
> module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id,
> sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444);
> MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe");
> --
> 2.14.1
>
Powered by blists - more mailing lists