From: zhong jiang <zhongjiang@huawei.com>
To: Joe Perches <golf@perches.com>
Cc: <tony.luck@intel.com>, <fenghua.yu@intel.com>,
<benh@kernel.crashing.org>, <paulus@samba.org>,
<mpe@ellerman.id.au>, <oleg@redhat.com>,
<rppt@linux.vnet.ibm.com>, <dhowells@redhat.com>,
<akpm@linux-foundation.org>, <viro@zeniv.linux.org.uk>,
<linux-ia64@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH 1/2] ia64: Use ARRAY_SIZE to replace its implementation
Date: Tue, 14 Aug 2018 12:57:08 +0800 [thread overview]
Message-ID: <5B726124.5030308@huawei.com> (raw)
In-Reply-To: <81ae2b1b7ea395217dbf3494457a232bdfdc79c5.camel@perches.com>
On 2018/8/14 12:45, Joe Perches wrote:
> On Tue, 2018-08-14 at 10:46 +0800, zhong jiang wrote:
>> We prefer to ARRAY_SIZE rather than duplicating its implementation.
>> So just replace it.
> []
>> diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
> []
>> @@ -4645,7 +4645,7 @@ static char *pfmfs_dname(struct dentry *dentry, char *buffer, int buflen)
>> /* 32 */PFM_CMD(pfm_write_ibrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL),
>> /* 33 */PFM_CMD(pfm_write_dbrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL)
>> };
>> -#define PFM_CMD_COUNT (sizeof(pfm_cmd_tab)/sizeof(pfm_cmd_desc_t))
>> +#define PFM_CMD_COUNT ARRAY_SIZE(pfm_cmd_tab)
> Better would be to remove the #define altogether and change
> the one place where it's used to ARRAY_SIZE(...)
> ---
> arch/ia64/kernel/perfmon.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
> index a9d4dc6c0427..08ece2c7b6e1 100644
> --- a/arch/ia64/kernel/perfmon.c
> +++ b/arch/ia64/kernel/perfmon.c
> @@ -4645,7 +4645,6 @@ static pfm_cmd_desc_t pfm_cmd_tab[]={
> /* 32 */PFM_CMD(pfm_write_ibrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL),
> /* 33 */PFM_CMD(pfm_write_dbrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL)
> };
> -#define PFM_CMD_COUNT (sizeof(pfm_cmd_tab)/sizeof(pfm_cmd_desc_t))
>
> static int
> pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags)
> @@ -4770,7 +4769,7 @@ sys_perfmonctl (int fd, int cmd, void __user *arg, int count)
> */
> if (unlikely(pmu_conf == NULL)) return -ENOSYS;
>
> - if (unlikely(cmd < 0 || cmd >= PFM_CMD_COUNT)) {
> + if (unlikely(cmd < 0 || cmd >= ARRAY_SIZE(pfm_cmd_tab)) {
> DPRINT(("invalid cmd=%d\n", cmd));
> return -EINVAL;
> }
>
>
> .
>
Thank you for suggestion. That's indeed better if just one palce use it. I will repost in v2.
Sincerely,
zhong jiang
next prev parent reply other threads:[~2018-08-14 4:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-14 2:46 [PATCH 0/2] Use ARRAY_SIZE to replace its implementation zhong jiang
2018-08-14 2:46 ` [PATCH 1/2] ia64: " zhong jiang
2018-08-14 4:45 ` Joe Perches
2018-08-14 4:57 ` zhong jiang [this message]
2018-08-14 2:46 ` [PATCH 2/2] powerpc: " zhong jiang
2018-08-14 4:49 ` Joe Perches
2018-08-14 9:28 ` Michael Ellerman
2018-08-14 10:28 ` zhong jiang
2018-08-14 16:18 ` [PATCH 0/2] " David Howells
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=5B726124.5030308@huawei.com \
--to=zhongjiang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=dhowells@redhat.com \
--cc=fenghua.yu@intel.com \
--cc=golf@perches.com \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=oleg@redhat.com \
--cc=paulus@samba.org \
--cc=rppt@linux.vnet.ibm.com \
--cc=tony.luck@intel.com \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).