aboutgitcodebugslistschat
path: root/Makefile
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-20 00:05:11 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-20 08:34:22 +0200
commit12cfa6444cd239dbc04391027ad3161f53b6901c (patch)
tree3fa746cef0cf3f543ebbe2e0d1535a331a1f2bd0 /Makefile
parent7f1e7019cbd47a13dde38782d4bc7430cecff8c4 (diff)
downloadpasst-12cfa6444cd239dbc04391027ad3161f53b6901c.tar
passt-12cfa6444cd239dbc04391027ad3161f53b6901c.tar.gz
passt-12cfa6444cd239dbc04391027ad3161f53b6901c.tar.bz2
passt-12cfa6444cd239dbc04391027ad3161f53b6901c.tar.lz
passt-12cfa6444cd239dbc04391027ad3161f53b6901c.tar.xz
passt-12cfa6444cd239dbc04391027ad3161f53b6901c.tar.zst
passt-12cfa6444cd239dbc04391027ad3161f53b6901c.zip
passt: Add clang-tidy Makefile target and test, take care of warnings
Most are just about style and form, but a few were actually serious mistakes (NDP-related). Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile75
1 files changed, 75 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 6d11e22..85d7400 100644
--- a/Makefile
+++ b/Makefile
@@ -87,3 +87,78 @@ pkgs:
fakeroot alien --to-rpm --target=$(shell uname -m) \
--description="User-mode networking for VMs and namespaces" \
-k --version=g$(shell git rev-parse --short HEAD) passt.tar.gz
+
+# Checkers currently disabled for clang-tidy:
+# - llvmlibc-restrict-system-libc-headers
+# TODO: this is Linux-only for the moment, nice to fix eventually
+#
+# - bugprone-macro-parentheses
+# - google-readability-braces-around-statements
+# - hicpp-braces-around-statements
+# - readability-braces-around-statements
+# Debatable whether that improves readability, right now it would look
+# like a mess
+#
+# - readability-magic-numbers
+# - cppcoreguidelines-avoid-magic-numbers
+# TODO: in most cases they are justified, but probably not everywhere
+#
+# - clang-analyzer-valist.Uninitialized
+# TODO: enable once https://bugs.llvm.org/show_bug.cgi?id=41311 is fixed
+#
+# - clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
+# Probably not doable to impement this without plain memcpy(), memset()
+#
+# - cppcoreguidelines-init-variables
+# Dubious value, would kill readability
+#
+# - hicpp-signed-bitwise
+# Those are needed for syscalls, epoll_wait flags, etc.
+#
+# - bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp
+# This flags _GNU_SOURCE, currently needed
+#
+# - llvm-include-order
+# TODO: not really important, but nice to fix eventually
+#
+# - readability-isolate-declaration
+# Dubious value, would kill readability
+#
+# - android-cloexec-open
+# - android-cloexec-pipe
+# - android-cloexec-pipe2
+# - android-cloexec-epoll-create1
+# TODO: check, fix except for the few cases where we need to share fds
+#
+# - bugprone-narrowing-conversions
+# - cppcoreguidelines-narrowing-conversions
+# TODO: nice to fix eventually
+#
+# - cppcoreguidelines-avoid-non-const-global-variables
+# TODO: check, fix, and more in general constify wherever possible
+#
+# - bugprone-suspicious-string-compare
+# Return value of memcmp(), not really suspicious
+clang-tidy: $(wildcard *.c)
+ clang-tidy -checks=*,-modernize-*,\
+ -clang-analyzer-valist.Uninitialized,\
+ -cppcoreguidelines-init-variables,\
+ -bugprone-macro-parentheses,\
+ -google-readability-braces-around-statements,\
+ -hicpp-braces-around-statements,\
+ -readability-braces-around-statements,\
+ -readability-magic-numbers,\
+ -llvmlibc-restrict-system-libc-headers,\
+ -hicpp-signed-bitwise,\
+ -bugprone-reserved-identifier,-cert-dcl37-c,-cert-dcl51-cpp,\
+ -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,\
+ -llvm-include-order,\
+ -cppcoreguidelines-avoid-magic-numbers,\
+ -readability-isolate-declaration,\
+ -android-cloexec-open,-android-cloexec-pipe,-android-cloexec-pipe2,\
+ -android-cloexec-epoll-create1,\
+ -bugprone-narrowing-conversions,\
+ -cppcoreguidelines-narrowing-conversions,\
+ -cppcoreguidelines-avoid-non-const-global-variables,\
+ -bugprone-suspicious-string-compare \
+ --warnings-as-errors=* $(wildcard *.c) -- $(CFLAGS)