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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230817143352.132583-3-lucas.segarra.fernandez@intel.com>
Date:   Thu, 17 Aug 2023 16:33:15 +0200
From:   Lucas Segarra Fernandez <lucas.segarra.fernandez@...el.com>
To:     herbert@...dor.apana.org.au, linux-kernel@...r.kernel.org
Cc:     linux-crypto@...r.kernel.org, qat-linux@...el.com,
        andriy.shevchenko@...el.com, alx.manpages@...il.com,
        Lucas Segarra Fernandez <lucas.segarra.fernandez@...el.com>,
        Giovanni Cabiddu <giovanni.cabiddu@...el.com>,
        Andy Shevchenko <andy.shevchenko@...il.com>
Subject: [PATCH 2/4] linux/array_size.h: Add ARRAY_SIZE_OF_FIELD()

Introduce ARRAY_SIZE_OF_FIELD() in order to get the number of elements
of an array struct field.

Signed-off-by: Lucas Segarra Fernandez <lucas.segarra.fernandez@...el.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@...el.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>
---
 include/linux/array_size.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/array_size.h b/include/linux/array_size.h
index 06d7d83196ca..37dac0473b5c 100644
--- a/include/linux/array_size.h
+++ b/include/linux/array_size.h
@@ -10,4 +10,12 @@
  */
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 
+/*
+ * ARRAY_SIZE_OF_FIELD - get the number of elements of an array struct field
+ *
+ * @TYPE: The structure containing the field of interest
+ * @MEMBER: The array field to be sized
+ */
+#define ARRAY_SIZE_OF_FIELD(TYPE, MEMBER) ARRAY_SIZE((((TYPE *)0)->MEMBER))
+
 #endif  /* _LINUX_ARRAY_SIZE_H */
-- 
2.41.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ