From 4fd83357254d2889e60c9e548e72ebe85f88d54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Sun, 6 Mar 2022 17:58:51 +0100 Subject: [PATCH] Improve include directives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update #include directives by removing such that aren't needed, and add such that should be there, since there's a direct dependencies to symbols or macros in them. Signed-off-by: Mattias Rönnblom --- include/xcm.h | 1 + include/xcm_attr_map.h | 2 +- libxcm/active_fd.c | 2 ++ libxcm/common_tp.c | 6 ++++++ libxcm/common_tp.h | 8 +++++++- libxcm/ctl.c | 4 ++-- libxcm/ctl.h | 4 +++- libxcm/ctx_store.c | 10 ++++++++-- libxcm/ctx_store.h | 3 +-- libxcm/log.c | 1 + libxcm/log.h | 5 ++--- libxcm/log_ctl.h | 1 - libxcm/log_tls.c | 1 + libxcm/log_tls.h | 1 + libxcm/log_tp.c | 7 +++++++ libxcm/log_tp.h | 7 ++----- libxcm/mbuf.h | 3 ++- libxcm/tcp_attr.c | 1 - libxcm/tcp_attr.h | 4 +--- libxcm/xcm.c | 7 ++----- libxcm/xcm_addr.c | 1 + libxcm/xcm_addr_compat.c | 4 +++- libxcm/xcm_attr_map.c | 1 + libxcm/xcm_compat.c | 4 +++- libxcm/xcm_dns.h | 3 +-- libxcm/xcm_dns_glibc.c | 7 +++++++ libxcm/xcm_tp.h | 2 -- libxcm/xcm_tp_btls.c | 12 +++++++++--- libxcm/xcm_tp_tcp.c | 2 -- libxcm/xcm_tp_tls.c | 2 -- libxcm/xcm_tp_utls.c | 6 +----- libxcm/xcm_tp_ux.c | 2 -- tools/xcmpong.c | 4 ++-- 33 files changed, 78 insertions(+), 50 deletions(-) diff --git a/include/xcm.h b/include/xcm.h index 01478a9a3..257f6e4fd 100644 --- a/include/xcm.h +++ b/include/xcm.h @@ -1260,6 +1260,7 @@ extern "C" { #include #include +#include #include #include diff --git a/include/xcm_attr_map.h b/include/xcm_attr_map.h index 0534cce75..5232f68c8 100644 --- a/include/xcm_attr_map.h +++ b/include/xcm_attr_map.h @@ -22,8 +22,8 @@ extern "C" { #include #include +#include #include -#include struct xcm_attr_map; diff --git a/libxcm/active_fd.c b/libxcm/active_fd.c index 2ea514c61..561fe9242 100644 --- a/libxcm/active_fd.c +++ b/libxcm/active_fd.c @@ -4,8 +4,10 @@ #include "util.h" #include +#include #include #include +#include /* * The Linux kernel limits the number of epoll instances fds the diff --git a/libxcm/common_tp.c b/libxcm/common_tp.c index 012c11adc..996249612 100644 --- a/libxcm/common_tp.c +++ b/libxcm/common_tp.c @@ -5,9 +5,15 @@ #include "common_tp.h" +#include "log_tp.h" #include "util.h" +#include "xcm.h" +#include "xcm_addr.h" +#include #include +#include +#include void tp_ip_to_sockaddr(const struct xcm_addr_ip *xcm_ip, uint16_t port, int64_t scope, struct sockaddr *sockaddr) diff --git a/libxcm/common_tp.h b/libxcm/common_tp.h index ebc388e04..9daa18eba 100644 --- a/libxcm/common_tp.h +++ b/libxcm/common_tp.h @@ -6,9 +6,15 @@ #ifndef COMMON_TP_H #define COMMON_TP_H -#include "log_tp.h" #include "xcm_addr.h" +#include +#include +#include +#include + +struct xcm_socket; + void tp_ip_to_sockaddr(const struct xcm_addr_ip *xcm_ip, uint16_t port, int64_t scope, struct sockaddr *sockaddr); diff --git a/libxcm/ctl.c b/libxcm/ctl.c index 38343a88b..e5d073faf 100644 --- a/libxcm/ctl.c +++ b/libxcm/ctl.c @@ -14,12 +14,12 @@ #include "xcm_attr.h" #include "xcm_tp.h" -#include #include #include +#include +#include #include #include -#include #include #define MAX_CLIENTS (2) diff --git a/libxcm/ctl.h b/libxcm/ctl.h index 6382ba11b..13c0f5efd 100644 --- a/libxcm/ctl.h +++ b/libxcm/ctl.h @@ -13,7 +13,9 @@ * from outside the process using XCM. */ -#include "xcm.h" +#include + +struct xcm_socket; struct ctl; diff --git a/libxcm/ctx_store.c b/libxcm/ctx_store.c index 424d630d2..f1223dda3 100644 --- a/libxcm/ctx_store.c +++ b/libxcm/ctx_store.c @@ -3,13 +3,19 @@ #include "log_tls.h" #include "util.h" -#include -#include +#include +#include +#include +#include + #include +#include #include +#include #include #include #include +#include /* OpenSSL 1.1.0 lacks TLS 1.3 support */ #ifdef SSL_OP_NO_TLSv1_3 diff --git a/libxcm/ctx_store.h b/libxcm/ctx_store.h index 57141c58d..684b37a15 100644 --- a/libxcm/ctx_store.h +++ b/libxcm/ctx_store.h @@ -1,8 +1,7 @@ #ifndef CTX_STORE #define CTX_STORE -#include -#include +#include void ctx_store_init(void); diff --git a/libxcm/log.c b/libxcm/log.c index 352540aae..59606d53a 100644 --- a/libxcm/log.c +++ b/libxcm/log.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/libxcm/log.h b/libxcm/log.h index 2f779955f..a7b14f703 100644 --- a/libxcm/log.h +++ b/libxcm/log.h @@ -6,11 +6,10 @@ #ifndef LOG_H #define LOG_H -#include "xcm.h" - -#include #include +struct xcm_socket; + #define log_event(type, sock, ...) \ do { \ if (log_is_enabled(type)) \ diff --git a/libxcm/log_ctl.h b/libxcm/log_ctl.h index b34b8a252..2a64e2cd3 100644 --- a/libxcm/log_ctl.h +++ b/libxcm/log_ctl.h @@ -6,7 +6,6 @@ #ifndef LOG_CTL_H #define LOG_CTL_H -#include "common_tp.h" #include "log.h" #define LOG_RUN_STAT_ERROR(s, path, reason_errno) \ diff --git a/libxcm/log_tls.c b/libxcm/log_tls.c index f50465f48..31b5bfa53 100644 --- a/libxcm/log_tls.c +++ b/libxcm/log_tls.c @@ -8,6 +8,7 @@ #include "util.h" #include +#include #include void hash_description(uint8_t *hash, size_t hash_len, char *buf) diff --git a/libxcm/log_tls.h b/libxcm/log_tls.h index 6440830f5..f4ea10df8 100644 --- a/libxcm/log_tls.h +++ b/libxcm/log_tls.h @@ -8,6 +8,7 @@ #include "log.h" +#include #include #define LOG_TLS_HANDSHAKE(s, client) \ diff --git a/libxcm/log_tp.c b/libxcm/log_tp.c index bc4d9e256..ba5fc507f 100644 --- a/libxcm/log_tp.c +++ b/libxcm/log_tp.c @@ -1,8 +1,15 @@ #include "log_tp.h" #include "util.h" +#include "xcm_attr_map.h" +#include #include +#include +#include +#include +#include +#include const char *log_ip_str(sa_family_t family, const void *ip) { diff --git a/libxcm/log_tp.h b/libxcm/log_tp.h index 80977fe85..e2c690c06 100644 --- a/libxcm/log_tp.h +++ b/libxcm/log_tp.h @@ -7,15 +7,12 @@ #define LOG_SOCK_H #include "log.h" +#include "xcm_addr.h" +#include "xcm_attr_map.h" #include "xcm_attr_types.h" -#include #include -#include #include -#include -#include -#include #include "common_tp.h" diff --git a/libxcm/mbuf.h b/libxcm/mbuf.h index 48dc25bbe..ad58b5262 100644 --- a/libxcm/mbuf.h +++ b/libxcm/mbuf.h @@ -12,8 +12,9 @@ #include "util.h" #include -#include +#include #include +#include #include #include diff --git a/libxcm/tcp_attr.c b/libxcm/tcp_attr.c index 1f38e81f7..3fa5c514f 100644 --- a/libxcm/tcp_attr.c +++ b/libxcm/tcp_attr.c @@ -8,7 +8,6 @@ #include "log_tp.h" #include "util.h" -#include #include #include #include diff --git a/libxcm/tcp_attr.h b/libxcm/tcp_attr.h index f5b0ae6ff..b661c90d9 100644 --- a/libxcm/tcp_attr.h +++ b/libxcm/tcp_attr.h @@ -6,10 +6,8 @@ #ifndef TCP_ATTR_H #define TCP_ATTR_H -#include "xcm_tp.h" - #include -#include +#include #define XCM_TCP_KEEPALIVE (true) #define XCM_TCP_KEEPALIVE_TIME (1) diff --git a/libxcm/xcm.c b/libxcm/xcm.c index a0fbef16f..dd4157394 100644 --- a/libxcm/xcm.c +++ b/libxcm/xcm.c @@ -7,19 +7,16 @@ #include "log_epoll.h" #include "util.h" -#include "xcm_addr.h" #include "xcm_attr_names.h" #include "xcm_tp.h" -#ifdef XCM_CTL -#include "ctl.h" -#endif - #include +#include #include #include #include #include +#include #define XCM_ENV_DEBUG "XCM_DEBUG" diff --git a/libxcm/xcm_addr.c b/libxcm/xcm_addr.c index 7970b446d..bfac7ab15 100644 --- a/libxcm/xcm_addr.c +++ b/libxcm/xcm_addr.c @@ -18,6 +18,7 @@ #include #include #include +#include static bool has_space(const char *s) { diff --git a/libxcm/xcm_addr_compat.c b/libxcm/xcm_addr_compat.c index a774b8371..8f7196b79 100644 --- a/libxcm/xcm_addr_compat.c +++ b/libxcm/xcm_addr_compat.c @@ -3,8 +3,10 @@ * Copyright(c) 2020 Ericsson AB */ -#include +#include +#include #include +#include #include static int delegate_parse(int (parse_fun)(const char *, struct xcm_addr_host *, diff --git a/libxcm/xcm_attr_map.c b/libxcm/xcm_attr_map.c index 9129aa007..49b7ab6f6 100644 --- a/libxcm/xcm_attr_map.c +++ b/libxcm/xcm_attr_map.c @@ -2,6 +2,7 @@ #include "util.h" +#include #include struct attr diff --git a/libxcm/xcm_compat.c b/libxcm/xcm_compat.c index a11cc4a0d..de0adac47 100644 --- a/libxcm/xcm_compat.c +++ b/libxcm/xcm_compat.c @@ -6,9 +6,11 @@ #include "xcm.h" #include "common_tp.h" -#include "util.h" +#include "log_tp.h" #include "xcm_tp.h" +#include + int xcm_want(struct xcm_socket *s, int condition, int *fds, int *events, size_t capacity) { diff --git a/libxcm/xcm_dns.h b/libxcm/xcm_dns.h index 40ed09573..6d10dc2a1 100644 --- a/libxcm/xcm_dns.h +++ b/libxcm/xcm_dns.h @@ -6,10 +6,9 @@ #ifndef XCM_DNS_H #define XCM_DNS_H -#include "xcm_tp.h" +#include "xcm_addr.h" #include -#include struct xcm_dns_query; diff --git a/libxcm/xcm_dns_glibc.c b/libxcm/xcm_dns_glibc.c index 656731b40..83a80bb31 100644 --- a/libxcm/xcm_dns_glibc.c +++ b/libxcm/xcm_dns_glibc.c @@ -9,9 +9,16 @@ #include "epoll_reg.h" #include "log_tp.h" #include "util.h" +#include "xcm_addr.h" #include #include +#include +#include +#include +#include +#include +#include enum query_state { query_state_resolving, diff --git a/libxcm/xcm_tp.h b/libxcm/xcm_tp.h index 2d999cf5b..187e79edb 100644 --- a/libxcm/xcm_tp.h +++ b/libxcm/xcm_tp.h @@ -6,8 +6,6 @@ #ifndef XCM_TP_H #define XCM_TP_H -#include - #include "config.h" #include "xcm.h" #include "xcm_addr_limits.h" diff --git a/libxcm/xcm_tp_btls.c b/libxcm/xcm_tp_btls.c index 545a2a5b9..97dbbd034 100644 --- a/libxcm/xcm_tp_btls.c +++ b/libxcm/xcm_tp_btls.c @@ -19,14 +19,20 @@ #include "xcm_dns.h" #include "xcm_tp.h" -#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include #include #include -#include #include #include +#include #include /* diff --git a/libxcm/xcm_tp_tcp.c b/libxcm/xcm_tp_tcp.c index ccfc9d0b8..5b4d7e11d 100644 --- a/libxcm/xcm_tp_tcp.c +++ b/libxcm/xcm_tp_tcp.c @@ -17,9 +17,7 @@ #include "xcm_dns.h" #include "xcm_tp.h" -#include #include -#include #include #include #include diff --git a/libxcm/xcm_tp_tls.c b/libxcm/xcm_tp_tls.c index de5013dca..56180b871 100644 --- a/libxcm/xcm_tp_tls.c +++ b/libxcm/xcm_tp_tls.c @@ -4,7 +4,6 @@ */ #include "common_tp.h" -#include "log_tls.h" #include "log_tp.h" #include "mbuf.h" #include "util.h" @@ -15,7 +14,6 @@ #include #include -#include /* * TLS XCM Transport diff --git a/libxcm/xcm_tp_utls.c b/libxcm/xcm_tp_utls.c index 642b30886..81217430f 100644 --- a/libxcm/xcm_tp_utls.c +++ b/libxcm/xcm_tp_utls.c @@ -3,9 +3,8 @@ * Copyright(c) 2020 Ericsson AB */ -#include "common_tp.h" +#include "config.h" #include "ctl.h" -#include "epoll_reg.h" #include "log_tp.h" #include "log_utls.h" #include "util.h" @@ -14,11 +13,8 @@ #include "xcm_addr_limits.h" #include "xcm_tp.h" -#include -#include #include #include -#include #include #include diff --git a/libxcm/xcm_tp_ux.c b/libxcm/xcm_tp_ux.c index 17428d387..8937c6684 100644 --- a/libxcm/xcm_tp_ux.c +++ b/libxcm/xcm_tp_ux.c @@ -13,11 +13,9 @@ #include "xcm_addr_limits.h" #include "xcm_tp.h" -#include #include #include #include -#include #include #include #include diff --git a/tools/xcmpong.c b/tools/xcmpong.c index cc9147bb2..8b155bcc2 100644 --- a/tools/xcmpong.c +++ b/tools/xcmpong.c @@ -6,16 +6,16 @@ #include "util.h" #include -#include #include #include +#include +#include #include #include #include #include #include #include -#include #include #include #include