diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-26 02:57:12 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-26 02:57:12 -0600 |
commit | 1dad21650eb6fb3a4b9bba6c0ddd1402930163e2 (patch) | |
tree | 0779682be9a5f22d8e7c33824319d291105fa2c8 | |
parent | 20ff819fc032fb6ae902022f12891ae7c9f73151 (diff) |
Lint for tabs-as-alignment
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | cmd/sbc_harness/hw/w5500.c | 22 | ||||
-rw-r--r-- | cmd/sbc_harness/hw/w5500_ll.h | 2 | ||||
-rw-r--r-- | cmd/srv9p/gnet.c | 14 | ||||
-rw-r--r-- | cmd/srv9p/main.c | 10 | ||||
-rwxr-xr-x | lib9p/idl.gen | 2 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.generated.h | 2 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.h | 4 | ||||
-rw-r--r-- | lib9p/internal.h | 24 | ||||
-rw-r--r-- | lib9p/map.h | 8 | ||||
-rw-r--r-- | lib9p/srv.c | 2 | ||||
-rw-r--r-- | libcr/coroutine.c | 32 | ||||
-rw-r--r-- | libcr_ipc/include/libcr_ipc/_linkedlist.h | 8 | ||||
-rw-r--r-- | libcr_ipc/include/libcr_ipc/select.h | 2 | ||||
-rw-r--r-- | libcr_ipc/include/libcr_ipc/sema.h | 2 | ||||
-rw-r--r-- | libdhcp/dhcp.c | 14 | ||||
-rw-r--r-- | libdhcp/include/libdhcp/dhcp.h | 4 |
17 files changed, 82 insertions, 77 deletions
@@ -89,7 +89,7 @@ lint/all: lint/%: -maxdepth 0 -type f | \ { r=0; while read -r filename; do \ if ! grep -q 'Copyright (C) 2024 Luke T. Shumaker' $$filename; then \ - echo "$$filename is missing a copyright statement"; r=1; continue; \ + echo "$$filename is missing a copyright statement"; r=1; \ fi; \ dscname=$$(sed -n '1,3{ /^#!/d; /^<!--$$/d; /-\*- .* -\*-/d; s,[/*# ]*,,; s/ - .*//;p; q; }' $$filename); \ filename_alt1=$$(echo "$$filename" | sed \ @@ -100,7 +100,10 @@ lint/all: lint/%: filename_alt2=$$(echo "$$filename_alt1" | sed \ -e 's,^sbc_harness/hw/,hw/,'); \ if ! { [ "$$dscname" == "$$filename" ] || [ "$$dscname" == "$$filename_alt1" ] || [ "$$dscname" == "$$filename_alt2" ]; }; then \ - echo "$$filename self-identifies as $$dscname"; r=1; continue; \ + echo "$$filename self-identifies as $$dscname"; r=1; \ + fi; \ + if grep -n --color=auto "$$(printf '\\S\t')" $$filename; then \ + echo "$$filename uses tabs for alignment"; r=1; \ fi; \ done; exit $$r; } .PHONY: lint lint/% diff --git a/cmd/sbc_harness/hw/w5500.c b/cmd/sbc_harness/hw/w5500.c index 6b90b99..a6cdc8b 100644 --- a/cmd/sbc_harness/hw/w5500.c +++ b/cmd/sbc_harness/hw/w5500.c @@ -84,14 +84,15 @@ * net.ipv4.ip_local_port_range, so I figure they're probably good * values to use. */ #ifndef CONFIG_W5500_LOCAL_PORT_MIN -# define CONFIG_W5500_LOCAL_PORT_MIN 32768 + #define CONFIG_W5500_LOCAL_PORT_MIN 32768 #endif + #ifndef CONFIG_W5500_LOCAL_PORT_MAX -# define CONFIG_W5500_LOCAL_PORT_MAX 60999 + #define CONFIG_W5500_LOCAL_PORT_MAX 60999 #endif #ifndef CONFIG_W5500_NUM -# error config.h must define CONFIG_W5500_NUM + #error config.h must define CONFIG_W5500_NUM #endif /* C language *****************************************************************/ @@ -101,13 +102,14 @@ /* mid-level utilities ********************************************************/ -/*static uint16_t w5500_get_local_port(struct w5500 *self) { - * uint16_t ret = self->next_local_port++; - * if (self->next_local_port > CONFIG_W5500_LOCAL_PORT_MAX) - * self->next_local_port = CONFIG_W5500_LOCAL_PORT_MIN; - * return ret; - *} - */ +#if 0 +static uint16_t w5500_get_local_port(struct w5500 *self) { + uint16_t ret = self->next_local_port++; + if (self->next_local_port > CONFIG_W5500_LOCAL_PORT_MAX) + self->next_local_port = CONFIG_W5500_LOCAL_PORT_MIN; + return ret; +} +#endif static COROUTINE w5500_irq_cr(void *_chip) { struct w5500 *chip = _chip; diff --git a/cmd/sbc_harness/hw/w5500_ll.h b/cmd/sbc_harness/hw/w5500_ll.h index 7c57ce8..4cc3b11 100644 --- a/cmd/sbc_harness/hw/w5500_ll.h +++ b/cmd/sbc_harness/hw/w5500_ll.h @@ -236,7 +236,7 @@ static_assert(sizeof(struct w5500ll_block_sock_reg) == 0x30); * * TCP state diagram, showing the flow of │ CLOSED │ ━━ role separator ┌───────┐ * SYN, FIN, and their assocaited ACKs. └────────┘ ══ state transition │ state │ - * V ┈┈ packet flow └───────┘ + * V ┈┈ packet flow └───────┘ * (CMD_OPEN) ║ * V (action/event) * ┌────────┐ diff --git a/cmd/srv9p/gnet.c b/cmd/srv9p/gnet.c index 39ad9b2..699deaf 100644 --- a/cmd/srv9p/gnet.c +++ b/cmd/srv9p/gnet.c @@ -50,14 +50,14 @@ static void gnet_init(void) { error(1, errno, "sigaction"); } -#define WAKE_COROUTINE(args) do { \ - int r; \ - union sigval val = {0}; \ - val.sival_int = (int)((args)->cr_coroutine); \ - do { \ +#define WAKE_COROUTINE(args) do { \ + int r; \ + union sigval val = {0}; \ + val.sival_int = (int)((args)->cr_coroutine); \ + do { \ r = pthread_sigqueue((args)->cr_thread, gnet_sig_io, val); \ - assert(r == 0 || r == EAGAIN); \ - } while (r == EAGAIN); \ + assert(r == 0 || r == EAGAIN); \ + } while (r == EAGAIN); \ } while (0) static inline bool RUN_PTHREAD(void *(*fn)(void *), void *args) { diff --git a/cmd/srv9p/main.c b/cmd/srv9p/main.c index 7ed985f..a2b437e 100644 --- a/cmd/srv9p/main.c +++ b/cmd/srv9p/main.c @@ -20,7 +20,7 @@ #include "config.h" #ifndef CONFIG_NETIO_NUM_CONNS -# error config.h must define CONFIG_NETIO_NUM_CONNS + #error config.h must define CONFIG_NETIO_NUM_CONNS #endif /* implementation *************************************************************/ @@ -31,11 +31,11 @@ #define FILE_COMMON(NAME) { \ .vtable = &static_file_vtable, \ - \ + \ .u_name = "root", .u_num = 0, /* owner user */ \ .g_name = "root", .g_num = 0, /* owner group */ \ .m_name = "root", .m_num = 0, /* last-modified-by user */ \ - \ + \ .pathnum = __COUNTER__, \ .name = NAME, \ .perm = 0444, \ @@ -45,11 +45,11 @@ #define DIR_COMMON(NAME) { \ .vtable = &static_dir_vtable, \ - \ + \ .u_name = "root", .u_num = 0, /* owner user */ \ .g_name = "root", .g_num = 0, /* owner group */ \ .m_name = "root", .m_num = 0, /* last-modified-by user */ \ - \ + \ .pathnum = __COUNTER__, \ .name = NAME, \ .perm = 0555, \ diff --git a/lib9p/idl.gen b/lib9p/idl.gen index a353a86..8a168b7 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -538,7 +538,7 @@ def gen_h(versions: set[str], typs: list[Type]) -> str: ret = f"""/* Generated by `{' '.join(sys.argv)}`. DO NOT EDIT! */ #ifndef _LIB9P_9P_H_ -# error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead + #error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead #endif #include <stdint.h> /* for uint{{n}}_t types */ diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h index ca7ca07..d5e94d1 100644 --- a/lib9p/include/lib9p/9p.generated.h +++ b/lib9p/include/lib9p/9p.generated.h @@ -1,7 +1,7 @@ /* Generated by `./lib9p/idl.gen lib9p/idl/2002-9P2000.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */ #ifndef _LIB9P_9P_H_ -# error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead + #error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead #endif #include <stdint.h> /* for uint{n}_t types */ diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h index a99cd5d..231556a 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/include/lib9p/9p.h @@ -18,10 +18,10 @@ #include "config.h" #ifndef CONFIG_9P_MAX_ERR_SIZE -# error config.h must define CONFIG_9P_MAX_ERR_SIZE + #error config.h must define CONFIG_9P_MAX_ERR_SIZE #endif #ifndef CONFIG_9P_ENABLE_9P2000 -# define CONFIG_9P_ENABLE_9P2000 + #define CONFIG_9P_ENABLE_9P2000 #endif /******************************************************************************/ diff --git a/lib9p/internal.h b/lib9p/internal.h index d78823d..c300be3 100644 --- a/lib9p/internal.h +++ b/lib9p/internal.h @@ -17,19 +17,19 @@ #include "config.h" #ifndef CONFIG_9P_MAX_MSG_SIZE -# error config.h must define CONFIG_9P_MAX_MSG_SIZE + #error config.h must define CONFIG_9P_MAX_MSG_SIZE #endif #ifndef CONFIG_9P_MAX_HOSTMSG_SIZE -# error config.h must define CONFIG_9P_MAX_HOSTMSG_SIZE + #error config.h must define CONFIG_9P_MAX_HOSTMSG_SIZE #endif #ifndef CONFIG_9P_MAX_FIDS -# error config.h must define CONFIG_9P_MAX_FIDS + #error config.h must define CONFIG_9P_MAX_FIDS #endif #ifndef CONFIG_9P_MAX_REQS -# error config.h must define CONFIG_9P_MAX_REQS + #error config.h must define CONFIG_9P_MAX_REQS #endif #ifndef CONFIG_9P_MAX_ERR_SIZE -# error config.h must define CONFIG_9P_MAX_ERR_SIZE + #error config.h must define CONFIG_9P_MAX_ERR_SIZE #endif static_assert(CONFIG_9P_MAX_ERR_SIZE <= UINT16_MAX); @@ -55,7 +55,7 @@ struct _validate_ctx { uint32_t net_offset; /* Increment `host_extra` to pre-allocate space that is * "extra" beyond sizeof(). */ - size_t host_extra; + size_t host_extra; }; typedef bool (*_validate_fn_t)(struct _validate_ctx *ctx); @@ -103,20 +103,20 @@ static ALWAYS_INLINE uint8_t decode_u8le(uint8_t *in) { return in[0]; } static ALWAYS_INLINE uint16_t decode_u16le(uint8_t *in) { - return (((uint16_t)(in[0])) << 0) - | (((uint16_t)(in[1])) << 8) + return (((uint16_t)(in[0])) << 0) + | (((uint16_t)(in[1])) << 8) ; } static ALWAYS_INLINE uint32_t decode_u32le(uint8_t *in) { - return (((uint32_t)(in[0])) << 0) - | (((uint32_t)(in[1])) << 8) + return (((uint32_t)(in[0])) << 0) + | (((uint32_t)(in[1])) << 8) | (((uint32_t)(in[2])) << 16) | (((uint32_t)(in[3])) << 24) ; } static ALWAYS_INLINE uint64_t decode_u64le(uint8_t *in) { - return (((uint64_t)(in[0])) << 0) - | (((uint64_t)(in[1])) << 8) + return (((uint64_t)(in[0])) << 0) + | (((uint64_t)(in[1])) << 8) | (((uint64_t)(in[2])) << 16) | (((uint64_t)(in[3])) << 24) | (((uint64_t)(in[4])) << 32) diff --git a/lib9p/map.h b/lib9p/map.h index a13edb5..458fe74 100644 --- a/lib9p/map.h +++ b/lib9p/map.h @@ -12,16 +12,16 @@ */ #ifndef NAME -# error NAME must be defined + #error NAME must be defined #endif #ifndef KEY_T -# error KEY_T must be defined + #error KEY_T must be defined #endif #ifndef VAL_T -# error VAL_T must be defined + #error VAL_T must be defined #endif #ifndef CAP -# error CAP must be defined + #error CAP must be defined #endif #ifndef MAP_KEY diff --git a/lib9p/srv.c b/lib9p/srv.c index 8eef372..83a6555 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -57,7 +57,7 @@ struct _srv_fidinfo { struct _srv_conn { /* immutable */ struct lib9p_srv *parent_srv; - implements_net_stream_conn *fd; + implements_net_stream_conn *fd; cid_t reader; /* the lib9p_srv_read_cr() coroutine */ /* mutable */ cr_mutex_t writelock; diff --git a/libcr/coroutine.c b/libcr/coroutine.c index 568de4e..e080644 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -17,26 +17,26 @@ #include "config.h" #ifndef CONFIG_COROUTINE_DEFAULT_STACK_SIZE -# error config.h must define CONFIG_COROUTINE_DEFAULT_STACK_SIZE + #error config.h must define CONFIG_COROUTINE_DEFAULT_STACK_SIZE #endif #ifndef CONFIG_COROUTINE_NUM -# error config.h must define CONFIG_COROUTINE_NUM + #error config.h must define CONFIG_COROUTINE_NUM #endif #ifndef CONFIG_COROUTINE_MEASURE_STACK -# error config.h must define CONFIG_COROUTINE_MEASURE_STACK + #error config.h must define CONFIG_COROUTINE_MEASURE_STACK #endif #ifndef CONFIG_COROUTINE_PROTECT_STACK -# error config.h must define CONFIG_COROUTINE_PROTECT_STACK + #error config.h must define CONFIG_COROUTINE_PROTECT_STACK #endif #ifndef CONFIG_COROUTINE_DEBUG -# error config.h must define CONFIG_COROUTINE_DEBUG + #error config.h must define CONFIG_COROUTINE_DEBUG #endif #ifndef CONFIG_COROUTINE_VALGRIND -# error config.h must define CONFIG_COROUTINE_VALGRIND + #error config.h must define CONFIG_COROUTINE_VALGRIND #endif #if CONFIG_COROUTINE_VALGRIND -# include <valgrind/valgrind.h> + #include <valgrind/valgrind.h> #endif /* Implementation *************************************************************/ @@ -309,10 +309,10 @@ static const uint8_t stack_pattern[] = { }; #endif #if CONFIG_COROUTINE_PROTECT_STACK -# define STACK_GUARD_SIZE \ + #define STACK_GUARD_SIZE \ ROUND_UP(sizeof(stack_pattern), CR_PLAT_STACK_ALIGNMENT) #else -# define STACK_GUARD_SIZE 0 + #define STACK_GUARD_SIZE 0 #endif /* global variables ***********************************************************/ @@ -358,20 +358,20 @@ static cid_t coroutine_running = 0; #define errorf(...) fprintf(stderr, "error: " __VA_ARGS__) #define infof(...) printf("info: " __VA_ARGS__) #if CONFIG_COROUTINE_DEBUG -# define debugf(...) printf("dbg: " __VA_ARGS__) + #define debugf(...) printf("dbg: " __VA_ARGS__) #else -# define debugf(...) + #define debugf(...) #endif #ifdef __GLIBC__ -# define assertf(expr, ...) ({ \ + #define assertf(expr, ...) ({ \ if (!(expr)) { \ errorf("assertion: " __VA_ARGS__); \ __assert_fail(#expr, __FILE__, __LINE__, __func__); \ } \ }) #else -# define assertf(expr, ...) assert(expr) + #define assertf(expr, ...) assert(expr) #endif static inline const char* coroutine_state_str(enum coroutine_state state) { @@ -406,10 +406,10 @@ static inline void assert_cid(cid_t cid) { #endif } -#define assert_cid_state(cid, expr) do { \ - assert_cid(cid); \ +#define assert_cid_state(cid, expr) do { \ + assert_cid(cid); \ cid_t state = coroutine_table[(cid)-1].state; \ - assert(expr); \ + assert(expr); \ } while (0) diff --git a/libcr_ipc/include/libcr_ipc/_linkedlist.h b/libcr_ipc/include/libcr_ipc/_linkedlist.h index 8e746c9..be1b293 100644 --- a/libcr_ipc/include/libcr_ipc/_linkedlist.h +++ b/libcr_ipc/include/libcr_ipc/_linkedlist.h @@ -21,12 +21,12 @@ * ex: * * typedef struct { - * MY_NODE *rear; + * MY_NODE *rear; * ...node_data... * } MY_NODE; * * typedef struct { - * MY_NODE *front, *rear; + * MY_NODE *front, *rear; * ...root_data... * } MY_ROOT; */ @@ -64,12 +64,12 @@ * ex: * * typedef struct { - * MY_NODE *front, *rear; + * MY_NODE *front, *rear; * ...node_data... * } MY_NODE; * * typedef struct { - * MY_NODE *front, *rear; + * MY_NODE *front, *rear; * ...root_data... * } MY_ROOT; */ diff --git a/libcr_ipc/include/libcr_ipc/select.h b/libcr_ipc/include/libcr_ipc/select.h index 2af85a2..94b7643 100644 --- a/libcr_ipc/include/libcr_ipc/select.h +++ b/libcr_ipc/include/libcr_ipc/select.h @@ -28,7 +28,7 @@ struct cr_select_arg { _CR_SELECT_OP_SEND, _CR_SELECT_OP_DEFAULT, } op; - struct _cr_chan *ch; + struct _cr_chan *ch; void *val_ptr; size_t val_siz; }; diff --git a/libcr_ipc/include/libcr_ipc/sema.h b/libcr_ipc/include/libcr_ipc/sema.h index 52ee670..aa749f9 100644 --- a/libcr_ipc/include/libcr_ipc/sema.h +++ b/libcr_ipc/include/libcr_ipc/sema.h @@ -24,7 +24,7 @@ struct _cr_sema_waiter { typedef struct { unsigned int cnt; struct { - struct _cr_sema_waiter *front, *rear; + struct _cr_sema_waiter *front, *rear; } waiters; } cr_sema_t; diff --git a/libdhcp/dhcp.c b/libdhcp/dhcp.c index 2fc7724..a1f54e6 100644 --- a/libdhcp/dhcp.c +++ b/libdhcp/dhcp.c @@ -75,16 +75,16 @@ #include "config.h" #ifndef CONFIG_DHCP_DEBUG -# define CONFIG_DHCP_DEBUG 1 + #define CONFIG_DHCP_DEBUG 1 #endif #ifndef CONFIG_DHCP_HOPS -# define CONFIG_DHCP_HOPS 0 + #define CONFIG_DHCP_HOPS 0 #endif #ifndef CONFIG_DHCP_SECS -# define CONFIG_DHCP_SECS 0 + #define CONFIG_DHCP_SECS 0 #endif #ifndef CONFIG_DHCP_OPT_SIZE -# define CONFIG_DHCP_OPT_SIZE 312 + #define CONFIG_DHCP_OPT_SIZE 312 #endif /* RFC 2131 definitions *******************************************************/ @@ -226,10 +226,10 @@ static const uint8_t dhcp_magic_cookie[] = {99, 130, 83, 99}; /* Implementation *************************************************************/ #if CONFIG_DHCP_DEBUG -# include <stdio.h> -# define debugf(fmt, ...) printf(fmt "\n" __VA_OPT__(,) __VA_ARGS__) + #include <stdio.h> + #define debugf(fmt, ...) printf(fmt "\n" __VA_OPT__(,) __VA_ARGS__) #else -# define debugf(fmt, ...) ((void)0) + #define debugf(fmt, ...) ((void)0) #endif /* DHCP state machine. */ diff --git a/libdhcp/include/libdhcp/dhcp.h b/libdhcp/include/libdhcp/dhcp.h index aae4a4d..660e154 100644 --- a/libdhcp/include/libdhcp/dhcp.h +++ b/libdhcp/include/libdhcp/dhcp.h @@ -1,4 +1,4 @@ -/* libdhcp/dhcp.c - A DHCP client +/* libdhcp/dhcp.h - A DHCP client * * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-Licence-Identifier: AGPL-3.0-or-later @@ -155,4 +155,4 @@ void xhandle(uint8_t opt_typ, uint8_t opt_len, uint8_t *opt_dat) { } } -#endif /* _LIBDHCP_DHCP_H_ */ +#endif /* _LIBDHCP_DHCP_H_ */ |