From 43686ff6732417c3bdf6aa9d4dac6da87dae983f Mon Sep 17 00:00:00 2001 From: Erik Olsson Date: Sat, 9 Jul 2022 22:33:23 +0200 Subject: [PATCH] Include used header files Make source files more self-contained by including the header files they use (and remove some they don't). This work was aided by the include_what_you_use tool. --- src/dump.c | 2 ++ src/error.c | 3 +++ src/hashtable_seed.c | 2 -- src/load.c | 4 ++-- src/pack_unpack.c | 4 ++++ src/strbuffer.c | 1 + src/strconv.c | 2 ++ src/utf.c | 1 - src/value.c | 3 +++ 9 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/dump.c b/src/dump.c index 28ff692e..a95bef9f 100644 --- a/src/dump.c +++ b/src/dump.c @@ -19,7 +19,9 @@ #include #endif +#include "hashtable.h" #include "jansson.h" +#include "jansson_config.h" #include "strbuffer.h" #include "utf.h" diff --git a/src/error.c b/src/error.c index 14d0047d..a37cb15b 100644 --- a/src/error.c +++ b/src/error.c @@ -1,4 +1,7 @@ +#include "jansson.h" #include "jansson_private.h" +#include +#include #include void jsonp_error_init(json_error_t *error, const char *source) { diff --git a/src/hashtable_seed.c b/src/hashtable_seed.c index d156b400..7cd6e67d 100644 --- a/src/hashtable_seed.c +++ b/src/hashtable_seed.c @@ -42,8 +42,6 @@ #include #endif -#include "jansson.h" - static uint32_t buf_to_uint32(char *data) { size_t i; uint32_t result = 0; diff --git a/src/load.c b/src/load.c index 8ae7abd1..83200e51 100644 --- a/src/load.c +++ b/src/load.c @@ -9,13 +9,13 @@ #define _GNU_SOURCE #endif +#include "jansson_config.h" #include "jansson_private.h" #include #include -#include +#include #include -#include #include #ifdef HAVE_UNISTD_H #include diff --git a/src/pack_unpack.c b/src/pack_unpack.c index a796ed4f..c0299dc2 100644 --- a/src/pack_unpack.c +++ b/src/pack_unpack.c @@ -7,8 +7,12 @@ */ #include "jansson.h" +#include "jansson_config.h" #include "jansson_private.h" +#include "hashtable.h" +#include "strbuffer.h" #include "utf.h" +#include #include typedef struct { diff --git a/src/strbuffer.c b/src/strbuffer.c index d9bcd439..05edbba7 100644 --- a/src/strbuffer.c +++ b/src/strbuffer.c @@ -11,6 +11,7 @@ #include "strbuffer.h" #include "jansson_private.h" +#include #include #include diff --git a/src/strconv.c b/src/strconv.c index 9e202c5c..7b104049 100644 --- a/src/strconv.c +++ b/src/strconv.c @@ -1,9 +1,11 @@ +#include "jansson_config.h" #include "jansson_private.h" #include "strbuffer.h" #include #include #include #include +#include #include /* need jansson_private_config.h to get the correct snprintf */ diff --git a/src/utf.c b/src/utf.c index 28b2f7d3..4583e226 100644 --- a/src/utf.c +++ b/src/utf.c @@ -6,7 +6,6 @@ */ #include "utf.h" -#include int utf8_encode(int32_t codepoint, char *buffer, size_t *size) { if (codepoint < 0) diff --git a/src/value.c b/src/value.c index d5a11fe5..07b51136 100644 --- a/src/value.c +++ b/src/value.c @@ -14,7 +14,9 @@ #endif #include +#include #include +#include #include #include @@ -24,6 +26,7 @@ #include "hashtable.h" #include "jansson.h" +#include "jansson_config.h" #include "jansson_private.h" #include "utf.h"