lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 26 Nov 2021 11:31:17 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Greg KH <greg@...ah.com>, cgel.zte@...il.com
Cc:     shuah@...nel.org, deng.changcheng@....com.cn, mlevitsk@...hat.com,
        kvm@...r.kernel.org, linux-kselftest@...r.kernel.org,
        linux-kernel@...r.kernel.org, Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] KVM: selftests: use ARRAY_SIZE

On 11/24/21 10:46, Greg KH wrote:
>> From: Changcheng Deng<deng.changcheng@....com.cn>
>>
>> Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
>>
>> Reported-by: Zeal Robot<zealci@....com.cn>
>> Signed-off-by: Changcheng Deng<deng.changcheng@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ