mbpfan-josie

Enable clang-tidy misc-include-cleaner

5c49f522a506d14b682a0d931ccc06d964556b9d
Andrew Gaul <andrew@gaul.org> · 2024-11-03T10:47 · browse files at this commit

parents: 905988c

diff --git a/.clang-tidy b/.clang-tidy
index dae158a..1175828 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -29,7 +29,6 @@ Checks: '
     -hicpp-*,
     -llvm-*,
     -llvmlibc-*,
-    -misc-include-cleaner,
     -misc-unused-parameters,
     -modernize-macro-to-enum,
     -readability-braces-around-statements,
diff --git a/src/daemon.c b/src/daemon.c
index 14a5b0d..e604131 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -16,15 +16,16 @@
  *
  */
 
+#include <linux/prctl.h>
 #include <sys/prctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdbool.h>
-#include <fcntl.h>
 #include <errno.h>
 #include <syslog.h>
+#include <sys/syslog.h>
 #include <string.h>
 #include <assert.h>
 #include <signal.h>
diff --git a/src/main.c b/src/main.c
index 7e5f1d6..c043253 100644
--- a/src/main.c
+++ b/src/main.c
@@ -20,14 +20,12 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
+#include <unistd.h>  // NOLINT(misc-include-cleaner)
 #include <syslog.h>
 #include <stdbool.h>
-#include <errno.h>
 #include "mbpfan.h"
 #include "daemon.h"
 #include "global.h"
-#include "util.h"
 
 void print_usage(int argc, char *argv[])
 {
@@ -46,7 +44,7 @@ int main(int argc, char *argv[])
 
     int c;
 
-    while ((c = getopt(argc, argv, "hfv|help")) != -1) {
+    while ((c = getopt(argc, argv, "hfv|help")) != -1) {  // NOLINT(misc-include-cleaner)
         switch (c) {
         case 'h':
             print_usage(argc, argv);
diff --git a/src/mbpfan.c b/src/mbpfan.c
index 39f67c5..b45788c 100644
--- a/src/mbpfan.c
+++ b/src/mbpfan.c
@@ -28,6 +28,8 @@
  *  Tested models: see README.md
  */
 
+#include <linux/limits.h>
+#include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -39,6 +41,7 @@
 #include <syslog.h>
 #include <stdbool.h>
 #include <dirent.h>
+#include <sys/syslog.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
 #include <sys/errno.h>
diff --git a/src/settings.c b/src/settings.c
index 32bdfb6..b89c143 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -34,7 +34,11 @@
  *    You should have received a copy of the GNU Lesser General Public License
  *    along with settings.  If not, see <http://www.gnu.org/licenses/>.
  */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "settings.h"
+#include "strmap.h"
 
 #define MAX_SECTIONCHARS 256
 #define MAX_KEYCHARS 256
diff --git a/src/settings.h b/src/settings.h
index 1698f9b..91266aa 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -31,12 +31,7 @@
 #ifndef _SETTINGS_H_
 #define _SETTINGS_H_
 
-#include <stdlib.h>
-#include <string.h>
 #include <stdio.h>
-#include <ctype.h>
-
-#include "strmap.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/strmap.c b/src/strmap.c
index f7d7dcc..deebb7b 100644
--- a/src/strmap.c
+++ b/src/strmap.c
@@ -33,6 +33,8 @@
  *    You should have received a copy of the GNU Lesser General Public License
  *    along with strmap.  If not, see <http://www.gnu.org/licenses/>.
  */
+#include <stdlib.h>
+#include <string.h>
 #include "strmap.h"
 
 typedef struct Pair Pair;
diff --git a/src/strmap.h b/src/strmap.h
index 5206cbb..4f7ade1 100644
--- a/src/strmap.h
+++ b/src/strmap.h
@@ -40,9 +40,6 @@
 extern "C" {
 #endif
 
-#include <stdlib.h>
-#include <string.h>
-
 typedef struct StrMap StrMap;
 
 /*
diff --git a/src/util.c b/src/util.c
index 0fbe3bf..df5b03f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -11,7 +11,7 @@ void mbp_log(int level, const char *fmt, ...)
     va_list args;
     if (daemonize) {
         va_start(args, fmt);
-        vsyslog(level, fmt, args);
+        vsyslog(level, fmt, args);  // NOLINT(misc-include-cleaner)
         va_end(args);
     }