From abefb51ceb4bcfecbb2ab5c7bdb0135f0d4fc5cf Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Thu, 27 Mar 2025 11:06:41 -0700 Subject: [PATCH] Clang-Tidy: Add loop checks Add bugprone-infinite-loop and bugprone-too-small-loop-variable. Make bugprone-infinite-loop an error. Clang-Tidy checks apparently need to be specified in one blob. Do so in each of our config files. --- .clang-tidy | 6 ++---- epan/dfilter/.clang-tidy | 4 +--- epan/wslua/.clang-tidy | 4 +--- tools/.clang-tidy | 4 +--- wsutil/.clang-tidy | 4 +--- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 83b34f8490..df56e647f7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -13,10 +13,8 @@ ExtraArgs: # Checks to run. A complete list of checks can be found at # https://clang.llvm.org/extra/clang-tidy/checks/list.html -Checks: - - '-*' - - 'misc-no-recursion' +Checks: '-*,misc-no-recursion,bugprone-infinite-loop,bugprone-too-small-loop-variable' -WarningsAsErrors: 'misc-no-recursion' +WarningsAsErrors: 'misc-no-recursion,bugprone-infinite-loop' UseColor: true diff --git a/epan/dfilter/.clang-tidy b/epan/dfilter/.clang-tidy index 84ea05375b..0d51e24c9b 100644 --- a/epan/dfilter/.clang-tidy +++ b/epan/dfilter/.clang-tidy @@ -3,8 +3,6 @@ InheritParentConfig: true # We don't want to do any checks in this directory yet so hack around # the fact that Clang-Tidy won't let us disable all checks. # https://stackoverflow.com/a/58379342/82195 -Checks: - - '-*' - - 'misc-definitions-in-headers' +Checks: '-*,misc-definitions-in-headers' CheckOptions: - { key: 'HeaderFileExtensions', value: 'DISABLED' } diff --git a/epan/wslua/.clang-tidy b/epan/wslua/.clang-tidy index 84ea05375b..0d51e24c9b 100644 --- a/epan/wslua/.clang-tidy +++ b/epan/wslua/.clang-tidy @@ -3,8 +3,6 @@ InheritParentConfig: true # We don't want to do any checks in this directory yet so hack around # the fact that Clang-Tidy won't let us disable all checks. # https://stackoverflow.com/a/58379342/82195 -Checks: - - '-*' - - 'misc-definitions-in-headers' +Checks: '-*,misc-definitions-in-headers' CheckOptions: - { key: 'HeaderFileExtensions', value: 'DISABLED' } diff --git a/tools/.clang-tidy b/tools/.clang-tidy index 84ea05375b..0d51e24c9b 100644 --- a/tools/.clang-tidy +++ b/tools/.clang-tidy @@ -3,8 +3,6 @@ InheritParentConfig: true # We don't want to do any checks in this directory yet so hack around # the fact that Clang-Tidy won't let us disable all checks. # https://stackoverflow.com/a/58379342/82195 -Checks: - - '-*' - - 'misc-definitions-in-headers' +Checks: '-*,misc-definitions-in-headers' CheckOptions: - { key: 'HeaderFileExtensions', value: 'DISABLED' } diff --git a/wsutil/.clang-tidy b/wsutil/.clang-tidy index 84ea05375b..0d51e24c9b 100644 --- a/wsutil/.clang-tidy +++ b/wsutil/.clang-tidy @@ -3,8 +3,6 @@ InheritParentConfig: true # We don't want to do any checks in this directory yet so hack around # the fact that Clang-Tidy won't let us disable all checks. # https://stackoverflow.com/a/58379342/82195 -Checks: - - '-*' - - 'misc-definitions-in-headers' +Checks: '-*,misc-definitions-in-headers' CheckOptions: - { key: 'HeaderFileExtensions', value: 'DISABLED' }