Skip to content

Commit

Permalink
Improve include directives
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
m-ronnblom committed Mar 6, 2022
1 parent 3ba4cbb commit 4fd8335
Show file tree
Hide file tree
Showing 33 changed files with 78 additions and 50 deletions.
1 change: 1 addition & 0 deletions include/xcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,7 @@ extern "C" {

#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>
#include <xcm_attr_map.h>

Expand Down
2 changes: 1 addition & 1 deletion include/xcm_attr_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ extern "C" {
#include <xcm_attr_types.h>

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>

struct xcm_attr_map;

Expand Down
2 changes: 2 additions & 0 deletions libxcm/active_fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#include "util.h"

#include <pthread.h>
#include <stddef.h>
#include <sys/eventfd.h>
#include <sys/queue.h>
#include <unistd.h>

/*
* The Linux kernel limits the number of epoll instances fds the
Expand Down
6 changes: 6 additions & 0 deletions libxcm/common_tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

#include "common_tp.h"

#include "log_tp.h"
#include "util.h"
#include "xcm.h"
#include "xcm_addr.h"

#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>

void tp_ip_to_sockaddr(const struct xcm_addr_ip *xcm_ip, uint16_t port,
int64_t scope, struct sockaddr *sockaddr)
Expand Down
8 changes: 7 additions & 1 deletion libxcm/common_tp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
#ifndef COMMON_TP_H
#define COMMON_TP_H

#include "log_tp.h"
#include "xcm_addr.h"

#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

struct xcm_socket;

void tp_ip_to_sockaddr(const struct xcm_addr_ip *xcm_ip, uint16_t port,
int64_t scope, struct sockaddr *sockaddr);

Expand Down
4 changes: 2 additions & 2 deletions libxcm/ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#include "xcm_attr.h"
#include "xcm_tp.h"

#include <assert.h>
#include <linux/un.h>
#include <stdio.h>
#include <string.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#define MAX_CLIENTS (2)
Expand Down
4 changes: 3 additions & 1 deletion libxcm/ctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
* from outside the process using XCM.
*/

#include "xcm.h"
#include <stdbool.h>

struct xcm_socket;

struct ctl;

Expand Down
10 changes: 8 additions & 2 deletions libxcm/ctx_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
#include "log_tls.h"
#include "util.h"

#include <openssl/x509_vfy.h>
#include <openssl/x509v3.h>
#include <openssl/sha.h>
#include <openssl/ssl.h>
#include <openssl/ssl3.h>
#include <openssl/x509.h>

#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>

/* OpenSSL 1.1.0 lacks TLS 1.3 support */
#ifdef SSL_OP_NO_TLSv1_3
Expand Down
3 changes: 1 addition & 2 deletions libxcm/ctx_store.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef CTX_STORE
#define CTX_STORE

#include <openssl/ssl.h>
#include <stdbool.h>
#include <openssl/ossl_typ.h>

void ctx_store_init(void);

Expand Down
1 change: 1 addition & 0 deletions libxcm/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <inttypes.h>
#include <libgen.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
Expand Down
5 changes: 2 additions & 3 deletions libxcm/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
#ifndef LOG_H
#define LOG_H

#include "xcm.h"

#include <stdarg.h>
#include <stdbool.h>

struct xcm_socket;

#define log_event(type, sock, ...) \
do { \
if (log_is_enabled(type)) \
Expand Down
1 change: 0 additions & 1 deletion libxcm/log_ctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
1 change: 1 addition & 0 deletions libxcm/log_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "util.h"

#include <openssl/err.h>
#include <stdio.h>
#include <string.h>

void hash_description(uint8_t *hash, size_t hash_len, char *buf)
Expand Down
1 change: 1 addition & 0 deletions libxcm/log_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "log.h"

#include <stddef.h>
#include <stdint.h>

#define LOG_TLS_HANDSHAKE(s, client) \
Expand Down
7 changes: 7 additions & 0 deletions libxcm/log_tp.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#include "log_tp.h"

#include "util.h"
#include "xcm_attr_map.h"

#include <arpa/inet.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <sys/socket.h>

const char *log_ip_str(sa_family_t family, const void *ip)
{
Expand Down
7 changes: 2 additions & 5 deletions libxcm/log_tp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <arpa/inet.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <xcm_attr_map.h>

#include "common_tp.h"

Expand Down
3 changes: 2 additions & 1 deletion libxcm/mbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#include "util.h"

#include <assert.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

Expand Down
1 change: 0 additions & 1 deletion libxcm/tcp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "log_tp.h"
#include "util.h"

#include <arpa/inet.h>
#include <errno.h>
#include <limits.h>
#include <netinet/in.h>
Expand Down
4 changes: 1 addition & 3 deletions libxcm/tcp_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#ifndef TCP_ATTR_H
#define TCP_ATTR_H

#include "xcm_tp.h"

#include <stdbool.h>
#include <sys/types.h>
#include <stdint.h>

#define XCM_TCP_KEEPALIVE (true)
#define XCM_TCP_KEEPALIVE_TIME (1)
Expand Down
7 changes: 2 additions & 5 deletions libxcm/xcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <poll.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/epoll.h>

#define XCM_ENV_DEBUG "XCM_DEBUG"

Expand Down
1 change: 1 addition & 0 deletions libxcm/xcm_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>

static bool has_space(const char *s)
{
Expand Down
4 changes: 3 additions & 1 deletion libxcm/xcm_addr_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* Copyright(c) 2020 Ericsson AB
*/

#include <assert.h>
#include <netinet/in.h>
#include <stdint.h>
#include <string.h>
#include <sys/socket.h>
#include <xcm_addr.h>

static int delegate_parse(int (parse_fun)(const char *, struct xcm_addr_host *,
Expand Down
1 change: 1 addition & 0 deletions libxcm/xcm_attr_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "util.h"

#include <string.h>
#include <sys/queue.h>

struct attr
Expand Down
4 changes: 3 additions & 1 deletion libxcm/xcm_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#include "xcm.h"

#include "common_tp.h"
#include "util.h"
#include "log_tp.h"
#include "xcm_tp.h"

#include <string.h>

int xcm_want(struct xcm_socket *s, int condition, int *fds,
int *events, size_t capacity)
{
Expand Down
3 changes: 1 addition & 2 deletions libxcm/xcm_dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
#ifndef XCM_DNS_H
#define XCM_DNS_H

#include "xcm_tp.h"
#include "xcm_addr.h"

#include <stdbool.h>
#include <xcm_addr.h>

struct xcm_dns_query;

Expand Down
7 changes: 7 additions & 0 deletions libxcm/xcm_dns_glibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
#include "epoll_reg.h"
#include "log_tp.h"
#include "util.h"
#include "xcm_addr.h"

#include <netdb.h>
#include <signal.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>

enum query_state {
query_state_resolving,
Expand Down
2 changes: 0 additions & 2 deletions libxcm/xcm_tp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#ifndef XCM_TP_H
#define XCM_TP_H

#include <sys/types.h>

#include "config.h"
#include "xcm.h"
#include "xcm_addr_limits.h"
Expand Down
12 changes: 9 additions & 3 deletions libxcm/xcm_tp_btls.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@
#include "xcm_dns.h"
#include "xcm_tp.h"

#include <arpa/inet.h>
#include <limits.h>
#include <netinet/in.h>
#include <openssl/asn1.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/obj_mac.h>
#include <openssl/ossl_typ.h>
#include <openssl/safestack.h>
#include <openssl/ssl3.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>

/*
Expand Down
2 changes: 0 additions & 2 deletions libxcm/xcm_tp_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include "xcm_dns.h"
#include "xcm_tp.h"

#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
Expand Down
2 changes: 0 additions & 2 deletions libxcm/xcm_tp_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

#include "common_tp.h"
#include "log_tls.h"
#include "log_tp.h"
#include "mbuf.h"
#include "util.h"
Expand All @@ -15,7 +14,6 @@

#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/*
* TLS XCM Transport
Expand Down
Loading

0 comments on commit 4fd8335

Please sign in to comment.