From 6d5a04005dd1dff12ebfe2e3a56912ec26718f3f Mon Sep 17 00:00:00 2001
From: NRK <nrk@disroot.org>
Date: Tue, 31 May 2022 17:25:14 +0600
Subject: code-style: cleanup includes

* rm unused include <sys/types.h>
* move <sys/time.h> to main.c, it's the only file that needs it.
* move TV_* macros to main.c
* let *.c files explicitly include what they need instead of including
  them at nsxiv.h
---
 commands.c |  1 +
 image.c    |  1 -
 main.c     | 10 ++++++++++
 nsxiv.h    | 14 +-------------
 options.c  |  1 +
 thumbs.c   |  2 +-
 util.c     |  3 ++-
 7 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/commands.c b/commands.c
index 2c4f4a7..8a73462 100644
--- a/commands.c
+++ b/commands.c
@@ -20,6 +20,7 @@
 #include "nsxiv.h"
 
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #include <sys/wait.h>
diff --git a/image.c b/image.c
index bcefa54..05459cf 100644
--- a/image.c
+++ b/image.c
@@ -26,7 +26,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <unistd.h>
 
 #if HAVE_LIBEXIF
diff --git a/main.c b/main.c
index 64710f2..10f7440 100644
--- a/main.c
+++ b/main.c
@@ -23,6 +23,8 @@
 #include "config.h"
 
 #include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -33,12 +35,20 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <time.h>
+#include <sys/time.h>
 #include <X11/keysym.h>
 #include <X11/XF86keysym.h>
 
 #define MODMASK(mask) ((mask) & USED_MODMASK)
 #define BAR_SEP "  "
 
+#define TV_DIFF(t1,t2) (((t1)->tv_sec  - (t2)->tv_sec ) * 1000 + \
+                        ((t1)->tv_usec - (t2)->tv_usec) / 1000)
+#define TV_ADD_MSEC(tv,t) {             \
+  (tv)->tv_sec  += (t) / 1000;          \
+  (tv)->tv_usec += (t) % 1000 * 1000;   \
+}
+
 typedef struct {
 	struct timeval when;
 	bool active;
diff --git a/nsxiv.h b/nsxiv.h
index 38e1d7b..eb06328 100644
--- a/nsxiv.h
+++ b/nsxiv.h
@@ -20,11 +20,8 @@
 #ifndef NSXIV_H
 #define NSXIV_H
 
-#include <stdarg.h>
+#include <stddef.h>
 #include <stdbool.h>
-#include <stdio.h>
-#include <sys/time.h>
-#include <sys/types.h>
 #include <Imlib2.h>
 #include <X11/Xlib.h>
 
@@ -39,17 +36,8 @@
 #define ABS(a) ((a) > 0 ? (a) : -(a))
 
 #define ARRLEN(a) (sizeof(a) / sizeof((a)[0]))
-
 #define STREQ(s1,s2) (strcmp((s1), (s2)) == 0)
 
-#define TV_DIFF(t1,t2) (((t1)->tv_sec  - (t2)->tv_sec ) * 1000 + \
-                        ((t1)->tv_usec - (t2)->tv_usec) / 1000)
-
-#define TV_ADD_MSEC(tv,t) {             \
-  (tv)->tv_sec  += (t) / 1000;          \
-  (tv)->tv_usec += (t) % 1000 * 1000;   \
-}
-
 typedef enum {
 	MODE_ALL,
 	MODE_IMAGE,
diff --git a/options.c b/options.c
index 8ae5c7e..8fade87 100644
--- a/options.c
+++ b/options.c
@@ -21,6 +21,7 @@
 #include "version.h"
 
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
diff --git a/thumbs.c b/thumbs.c
index b8ba2d1..8341014 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -22,9 +22,9 @@
 #include "config.h"
 
 #include <errno.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <utime.h>
diff --git a/util.c b/util.c
index 9c97dda..31ab4b8 100644
--- a/util.c
+++ b/util.c
@@ -21,8 +21,9 @@
 
 #include <assert.h>
 #include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
-- 
cgit v1.2.3