public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Greg KH <greg@kroah.com>, cgel.zte@gmail.com
Cc: shuah@kernel.org, deng.changcheng@zte.com.cn,
	mlevitsk@redhat.com, kvm@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] KVM: selftests: use ARRAY_SIZE
Date: Fri, 26 Nov 2021 11:31:17 +0100	[thread overview]
Message-ID: <48dc971d-e5ee-0024-e539-89a050e7cf5e@redhat.com> (raw)
In-Reply-To: <YZ4J23oFTTDpjSa8@kroah.com>

On 11/24/21 10:46, Greg KH wrote:
>> From: Changcheng Deng<deng.changcheng@zte.com.cn>
>>
>> Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
>>
>> Reported-by: Zeal Robot<zealci@zte.com.cn>
>> Signed-off-by: Changcheng Deng<deng.changcheng@zte.com.cn>
> Your email address does not match these here, you need to provide a
> signed-off-by as well.
> 
> And are you_SURE_  that you can use kernel #defines in userspace testing
> code?

Dpeends on which, but ARRAY_SIZE is among those that can be used:

$ git grep '#define ARRAY_SIZE' 'tools/*.h'
tools/gpio/gpio-utils.h:#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
tools/iio/iio_utils.h:#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
tools/include/linux/kernel.h:#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
tools/testing/selftests/bpf/progs/profiler.inc.h:#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
tools/testing/selftests/cgroup/cgroup_util.h:#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
tools/testing/selftests/kselftest_harness.h:#define ARRAY_SIZE(a)	(sizeof(a) / sizeof(a[0]))
tools/testing/selftests/landlock/common.h:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
tools/testing/selftests/vm/pkey-helpers.h:#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
tools/virtio/linux/kernel.h:#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))

In particular, most KVM tests already include linux/kernel.h
indirectly via linux/list.h.

Paolo


      reply	other threads:[~2021-11-26 10:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  9:22 [PATCH] KVM: selftests: use ARRAY_SIZE cgel.zte
2021-11-24  9:46 ` Greg KH
2021-11-26 10:31   ` Paolo Bonzini [this message]

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=48dc971d-e5ee-0024-e539-89a050e7cf5e@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=cgel.zte@gmail.com \
    --cc=deng.changcheng@zte.com.cn \
    --cc=greg@kroah.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=shuah@kernel.org \
    --cc=zealci@zte.com.cn \
    /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