From patchwork Sun Oct 1 19:30:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=A9r=C3=A9my_Lefaure?= X-Patchwork-Id: 9979857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA89D602A0 for ; Sun, 1 Oct 2017 19:41:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E16461FEBA for ; Sun, 1 Oct 2017 19:41:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D66A328AAF; Sun, 1 Oct 2017 19:41:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CCD41FEBA for ; Sun, 1 Oct 2017 19:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751773AbdJATlS (ORCPT ); Sun, 1 Oct 2017 15:41:18 -0400 Received: from blatinox.fr ([51.254.120.209]:33869 "EHLO vps202351.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751801AbdJATlO (ORCPT ); Sun, 1 Oct 2017 15:41:14 -0400 Received: from blatinox-laptop.localdomain (modemcable003.167-22-96.mc.videotron.ca [96.22.167.3]) by vps202351.ovh.net (Postfix) with ESMTPA id 8D4A61CAD6; Sun, 1 Oct 2017 21:31:25 +0200 (CEST) From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= To: Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe Cc: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/18] tpm: use ARRAY_SIZE Date: Sun, 1 Oct 2017 15:30:51 -0400 Message-Id: <20171001193101.8898-14-jeremy.lefaure@lse.epita.fr> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171001193101.8898-1-jeremy.lefaure@lse.epita.fr> References: <20171001193101.8898-1-jeremy.lefaure@lse.epita.fr> MIME-Version: 1.0 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Jarkko Sakkinen --- 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 #include #include +#include #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");