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: <20230819195005.99387-2-mahmoudmatook.mm@gmail.com>
Date: Sat, 19 Aug 2023 23:50:04 +0400
From: Mahmoud Maatuq <mahmoudmatook.mm@...il.com>
To: linux-kernel@...r.kernel.org,
	linux-kselftest@...r.kernel.org,
	kuba@...nel.org,
	netdev@...r.kernel.org,
	willemdebruijn.kernel@...il.com,
	davem@...emloft.net,
	pabeni@...hat.com,
	edumazet@...gle.com,
	shuah@...nel.org
Cc: linux-kernel-mentees@...ts.linuxfoundation.org,
	Mahmoud Maatuq <mahmoudmatook.mm@...il.com>
Subject: [PATCH 1/2] selftests: Provide local define of min() and max()

to avoid manual calculation of min and max values
and fix coccinelle warnings such WARNING opportunity for min()/max()
adding one common definition that could be used in multiple files
under selftests.
there are also some defines for min/max scattered locally inside sources
under selftests.
this also prepares for cleaning up those redundant defines and include
kselftest.h instead.

Signed-off-by: Mahmoud Maatuq <mahmoudmatook.mm@...il.com>
---
 tools/testing/selftests/kselftest.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index 829be379545a..e8eb7e9afbc6 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -55,6 +55,13 @@
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 #endif
 
+#ifndef min
+# define min(x, y) ((x) < (y) ? (x) : (y))
+#endif
+#ifndef max
+# define max(x, y) ((x) < (y) ? (y) : (x))
+#endif
+
 /*
  * gcc cpuid.h provides __cpuid_count() since v4.4.
  * Clang/LLVM cpuid.h provides  __cpuid_count() since v3.4.0.
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ