Cleanup includes

Improved manually with the help of neovim LSP warnings and iwyu:

    iwyu -Ibuilddir/app/ -Iapp/src/ app/src/XXX.c
This commit is contained in:
Romain Vimont
2024-12-20 20:58:41 +01:00
parent 5b1229a55f
commit af15c72f9c
110 changed files with 225 additions and 151 deletions

View File

@@ -1,7 +1,6 @@
#include "acksync.h"
#include <assert.h>
#include "util/log.h"
bool
sc_acksync_init(struct sc_acksync *as) {

View File

@@ -3,7 +3,10 @@
#include "common.h"
#include "thread.h"
#include <stdbool.h>
#include <stdint.h>
#include "util/thread.h"
#include "util/tick.h"
#define SC_SEQUENCE_INVALID 0

View File

@@ -6,6 +6,7 @@
#include <assert.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
/**

View File

@@ -3,9 +3,6 @@
#include "common.h"
#include <stdbool.h>
#include <stdint.h>
struct sc_average {
// Current average value
float avg;

View File

@@ -4,7 +4,6 @@
#include "common.h"
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
static inline void

View File

@@ -2,7 +2,9 @@
#include <stdlib.h>
#include <string.h>
#include "util/str.h"
#ifdef _WIN32
# include "util/str.h"
#endif
char *
sc_get_env(const char *varname) {

View File

@@ -3,6 +3,7 @@
#include "common.h"
#include <stddef.h>
#include <stdint.h>
struct sc_intmap_entry {

View File

@@ -1,9 +1,9 @@
#include "intr.h"
#include "util/log.h"
#include <assert.h>
#include "util/log.h"
bool
sc_intr_init(struct sc_intr *intr) {
bool ok = sc_mutex_init(&intr->mutex);

View File

@@ -6,9 +6,9 @@
#include <stdatomic.h>
#include <stdbool.h>
#include "net.h"
#include "process.h"
#include "thread.h"
#include "util/net.h"
#include "util/process.h"
#include "util/thread.h"
/**
* Interruptor to wake up a blocking call from another thread

View File

@@ -4,7 +4,10 @@
# include <windows.h>
#endif
#include <assert.h>
#include <libavformat/avformat.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <libavutil/log.h>
static SDL_LogPriority
log_level_sc_to_sdl(enum sc_log_level level) {

View File

@@ -1,28 +1,27 @@
#include "net.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include "log.h"
#ifdef _WIN32
# include <ws2tcpip.h>
typedef int socklen_t;
#else
# include <sys/types.h>
# include <sys/socket.h>
# include <arpa/inet.h>
# include <fcntl.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <arpa/inet.h>
# include <unistd.h>
# include <fcntl.h>
# include <sys/socket.h>
# include <sys/types.h>
# define SOCKET_ERROR -1
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
typedef struct in_addr IN_ADDR;
#endif
#include "util/log.h"
bool
net_init(void) {
#ifdef _WIN32

View File

@@ -4,14 +4,15 @@
#include "common.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#ifdef _WIN32
# include <winsock2.h>
typedef SOCKET sc_raw_socket;
# define SC_RAW_SOCKET_NONE INVALID_SOCKET
#else // not _WIN32
# include <sys/socket.h>
typedef int sc_raw_socket;
# define SC_RAW_SOCKET_NONE -1
#endif

View File

@@ -3,8 +3,13 @@
#include "common.h"
#include "intr.h"
#include "net.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "util/intr.h"
#include "util/net.h"
bool
net_connect_intr(struct sc_intr *intr, sc_socket socket, uint32_t addr,

View File

@@ -1,8 +1,6 @@
#include "process.h"
#include <assert.h>
#include <libgen.h>
#include "log.h"
enum sc_process_result
sc_process_execute(const char *const argv[], sc_pid *pid, unsigned flags) {

View File

@@ -4,7 +4,9 @@
#include "common.h"
#include <stdbool.h>
#include <stddef.h>
#include "util/thread.h"
#include "util/tick.h"
#ifdef _WIN32

View File

@@ -3,8 +3,8 @@
#include "common.h"
#include "intr.h"
#include "process.h"
#include "util/intr.h"
#include "util/process.h"
ssize_t
sc_pipe_read_intr(struct sc_intr *intr, sc_pid pid, sc_pipe pipe, char *data,

View File

@@ -12,8 +12,8 @@
# include <tchar.h>
#endif
#include "log.h"
#include "strbuf.h"
#include "util/log.h"
#include "util/strbuf.h"
size_t
sc_strncpy(char *dest, const char *src, size_t n) {

View File

@@ -5,6 +5,8 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
/* Stringify a numeric value */
#define SC_STR(s) SC_XSTR(s)

View File

@@ -1,11 +1,10 @@
#include "strbuf.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"
#include "util/log.h"
bool
sc_strbuf_init(struct sc_strbuf *buf, size_t init_cap) {

View File

@@ -1,10 +1,12 @@
#include "thread.h"
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <SDL2/SDL_thread.h>
#include "log.h"
#include "util/log.h"
sc_thread_id SC_MAIN_THREAD_ID;

View File

@@ -1,6 +1,7 @@
#include "tick.h"
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#ifdef _WIN32
# include <windows.h>

View File

@@ -1,8 +1,9 @@
#include "timeout.h"
#include <assert.h>
#include <stddef.h>
#include "log.h"
#include "util/log.h"
bool
sc_timeout_init(struct sc_timeout *timeout) {

View File

@@ -5,8 +5,8 @@
#include <stdbool.h>
#include "thread.h"
#include "tick.h"
#include "util/thread.h"
#include "util/tick.h"
struct sc_timeout {
sc_thread thread;

View File

@@ -6,6 +6,7 @@
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

View File

@@ -5,8 +5,8 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
// Adapted from vlc_vector:
// <https://code.videolan.org/videolan/vlc/-/blob/0857947abaed9c89810cd96353aaa1b7e6ba3b0d/include/vlc_vector.h>