]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check for atomic operations consistency in checklibs.sh
authorAydın Mercan <aydin@isc.org>
Mon, 18 Dec 2023 08:38:59 +0000 (11:38 +0300)
committerAydın Mercan <aydin@isc.org>
Wed, 3 Jan 2024 17:04:31 +0000 (17:04 +0000)
isc/atomic.h and its defined macros should be preferred over
stdatomic.h and explicit atomic operations.

Fix the redundant stdatomic.h header in histo.c found by the introduced
check.

lib/isc/histo.c
util/checklibs.sh

index fa4ca5b06d5917128bbae45d1b677405920e3695..7aac5c36ca36cf3df123e8cca9ca3f81a56cf4e8 100644 (file)
@@ -14,7 +14,6 @@
 #include <assert.h>
 #include <errno.h>
 #include <math.h>
-#include <stdatomic.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
index fdb9bee4947cceb3c25b9f77d1e4c1f622bdab92..e0f8c79d641b9df1fa721c870ed70425ce3c46c7 100755 (executable)
@@ -42,4 +42,26 @@ list=$(git grep -l uintptr_t lib bin \
   echo "$list"
 }
 
+#
+# Check for the direct usage of stdatomic.h
+#
+list=$(git grep -l stdatomic.h lib bin ':(exclude)lib/isc/include/isc/atomic\.h' \
+  | grep -e '\.c$' -e '\.h$')
+[ -n "$list" ] && {
+  status=1
+  echo 'Use #include <isc/atomic.h> instead of #include <stdatomic.h>:'
+  echo "$list"
+}
+
+#
+# Check for the usage of explicit memory ordering
+#
+list=$(git grep -l memory_order_.* lib bin ':(exclude)lib/isc/include/isc/atomic\.h' \
+  | grep -e '\.c$' -e '\.h$')
+[ -n "$list" ] && {
+  status=1
+  echo 'Prefer the helpers in <isc/atomic.h> over specifying an explicit memory order:'
+  echo "$list"
+}
+
 exit $status