summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-27 23:16:58 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-27 23:21:44 -0600
commit89761191a98f7dce4d1049b9a84c3d645378222a (patch)
tree4a60eab88b515af663171aa9bee343f46ca98115
parent7f3507b606b0f5c0c44cc59eb27e87575cf87701 (diff)
Lint that include-guards match the filename
-rw-r--r--Makefile18
-rw-r--r--cmd/sbc_harness/config/config.h2
-rw-r--r--cmd/sbc_harness/config/tusb_config.h2
-rw-r--r--cmd/sbc_harness/hw/rp2040_hwspi.h6
-rw-r--r--cmd/sbc_harness/usb_keyboard.h6
-rw-r--r--cmd/srv9p/config/config.h2
-rw-r--r--cmd/srv9p/gnet.h6
-rw-r--r--cmd/srv9p/static9p.h6
-rw-r--r--lib9p/include/lib9p/9p.h2
-rw-r--r--lib9p/map.h5
-rw-r--r--libcr/include/libcr/coroutine.h6
-rw-r--r--libcr_ipc/include/libcr_ipc/_linkedlist.h6
-rw-r--r--libcr_ipc/include/libcr_ipc/chan.h6
-rw-r--r--libcr_ipc/include/libcr_ipc/mutex.h6
-rw-r--r--libcr_ipc/include/libcr_ipc/rpc.h6
-rw-r--r--libcr_ipc/include/libcr_ipc/select.h6
-rw-r--r--libcr_ipc/include/libcr_ipc/sema.h6
-rw-r--r--libusb/include/libusb/usb_common.h6
18 files changed, 61 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index 0b22e66..bd4f9cc 100644
--- a/Makefile
+++ b/Makefile
@@ -69,6 +69,9 @@ generate-clean:
sources_all := $(foreach v,$(filter sources_%,$(.VARIABLES)),$($v))
# lint #############
+
+get_dscname = sed -n '1,3{ /^\#!/d; /^<!--$$/d; /-\*- .* -\*-/d; s,[/*\# ]*,,; s/ - .*//;p; q; }'
+
lint:
$(MAKE) -k $(patsubst sources_%,lint/%,$(filter sources_%,$(.VARIABLES)))
lint/sh lint/bash: lint/%:
@@ -78,7 +81,17 @@ lint/python3: lint/%:
black --check $(sources_$*)
isort --check $(sources_$*)
lint/c: lint/%:
- @: TODO
+ @for filename in $(filter %.h,$(sources_$*)); do \
+ dscname=$$($(get_dscname) $$filename); \
+ guard=$${dscname//'/'/'_'}; \
+ guard=$${guard//'.'/'_'}; \
+ guard="_$${guard^^}_"; \
+ if ! { grep -Fxq "#ifndef $${guard}" "$$filename" && \
+ grep -Fxq "#define $${guard}" "$$filename" && \
+ grep -Fxq "#endif /* $${guard} */" "$$filename"; }; then \
+ echo "$$filename does not have $${guard} guard"; r=1; \
+ fi; \
+ done
lint/make lint/cmake lint/gitignore lint/ini lint/9p lint/markdown: lint/%:
@:
lint/unknown: lint/%:
@@ -91,9 +104,10 @@ lint/all: lint/%:
if ! grep -q 'Copyright (C) 2024 Luke T. Shumaker' $$filename; then \
echo "$$filename is missing a copyright statement"; r=1; \
fi; \
- dscname=$$(sed -n '1,3{ /^#!/d; /^<!--$$/d; /-\*- .* -\*-/d; s,[/*# ]*,,; s/ - .*//;p; q; }' $$filename); \
+ dscname=$$($(get_dscname) $$filename); \
filename_alt1=$$(echo "$$filename" | sed \
-e 's,^cmd/,,' \
+ -e 's,.*/config/,,' \
-e 's,.*/include/,,' \
-e 's,^lib9p/idl/,,' \
-e 's/\.wip$$//'); \
diff --git a/cmd/sbc_harness/config/config.h b/cmd/sbc_harness/config/config.h
index c3e8bf3..483e815 100644
--- a/cmd/sbc_harness/config/config.h
+++ b/cmd/sbc_harness/config/config.h
@@ -1,4 +1,4 @@
-/* sbc_harness/config/config.h - Compile-time configuration for sbc_harness
+/* config.h - Compile-time configuration for sbc_harness
*
* Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-Licence-Identifier: AGPL-3.0-or-later
diff --git a/cmd/sbc_harness/config/tusb_config.h b/cmd/sbc_harness/config/tusb_config.h
index 74561f3..47ebc3e 100644
--- a/cmd/sbc_harness/config/tusb_config.h
+++ b/cmd/sbc_harness/config/tusb_config.h
@@ -1,4 +1,4 @@
-/* sbc_harness/config/tusb_config.h - Compile-time configuration for the TinyUSB library
+/* tusb_config.h - Compile-time configuration for the TinyUSB library
*
* Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-Licence-Identifier: AGPL-3.0-or-later
diff --git a/cmd/sbc_harness/hw/rp2040_hwspi.h b/cmd/sbc_harness/hw/rp2040_hwspi.h
index 8cf8aff..393eae6 100644
--- a/cmd/sbc_harness/hw/rp2040_hwspi.h
+++ b/cmd/sbc_harness/hw/rp2040_hwspi.h
@@ -5,8 +5,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _RP2040_HWSPI_H_
-#define _RP2040_HWSPI_H_
+#ifndef _HW_RP2040_HWSPI_H_
+#define _HW_RP2040_HWSPI_H_
#include <pico/binary_info.h> /* for bi_* */
@@ -60,4 +60,4 @@ void _rp2040_hwspi_init(struct rp2040_hwspi *self,
uint pin_clk,
uint pin_cs);
-#endif /* _RP2040_HWSPI_H_ */
+#endif /* _HW_RP2040_HWSPI_H_ */
diff --git a/cmd/sbc_harness/usb_keyboard.h b/cmd/sbc_harness/usb_keyboard.h
index 2227220..f3593f3 100644
--- a/cmd/sbc_harness/usb_keyboard.h
+++ b/cmd/sbc_harness/usb_keyboard.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _USB_KEYBOARD_H_
-#define _USB_KEYBOARD_H_
+#ifndef _SBC_HARNESS_USB_KEYBOARD_H_
+#define _SBC_HARNESS_USB_KEYBOARD_H_
#include <stdint.h> /* for uint32_t */
@@ -17,4 +17,4 @@ CR_RPC_DECLARE(usb_keyboard_rpc, uint32_t, int)
void usb_keyboard_init(void);
COROUTINE usb_keyboard_cr(void *arg);
-#endif /* _USB_KEYBOARD_H_ */
+#endif /* _SBC_HARNESS_USB_KEYBOARD_H_ */
diff --git a/cmd/srv9p/config/config.h b/cmd/srv9p/config/config.h
index fa6faeb..0f6c37e 100644
--- a/cmd/srv9p/config/config.h
+++ b/cmd/srv9p/config/config.h
@@ -1,4 +1,4 @@
-/* srv9p/config/config.h - Compile-time configuration for srv9p
+/* config.h - Compile-time configuration for srv9p
*
* Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-Licence-Identifier: AGPL-3.0-or-later
diff --git a/cmd/srv9p/gnet.h b/cmd/srv9p/gnet.h
index 4380c1d..3e8a0f4 100644
--- a/cmd/srv9p/gnet.h
+++ b/cmd/srv9p/gnet.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _GNET_H_
-#define _GNET_H_
+#ifndef _SRV9P_GNET_H_
+#define _SRV9P_GNET_H_
#include <stdint.h> /* for uint16_6 */
@@ -34,4 +34,4 @@ struct gnet_udp_conn {
void gnet_udp_conn_init(struct gnet_udp_conn *self, uint16_t port);
-#endif /* _GNET_H_ */
+#endif /* _SRV9P_GNET_H_ */
diff --git a/cmd/srv9p/static9p.h b/cmd/srv9p/static9p.h
index e03a480..5ef6cb1 100644
--- a/cmd/srv9p/static9p.h
+++ b/cmd/srv9p/static9p.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _STATIC9P_H_
-#define _STATIC9P_H_
+#ifndef _SRV9P_STATIC9P_H_
+#define _SRV9P_STATIC9P_H_
#include <lib9p/srv.h>
@@ -44,4 +44,4 @@ struct static_file {
extern struct lib9p_srv_file_vtable static_dir_vtable;
extern struct lib9p_srv_file_vtable static_file_vtable;
-#endif /* _STATIC9P_H_ */
+#endif /* _SRV9P_STATIC9P_H_ */
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index 231556a..9a91c41 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -165,4 +165,4 @@ uint32_t lib9p_unmarshal_stat(struct lib9p_ctx *ctx, uint8_t *net_bytes,
uint32_t lib9p_marshal_stat(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj,
uint8_t *ret_bytes);
-#endif _LIB9P_9P_H_
+#endif /* _LIB9P_9P_H_ */
diff --git a/lib9p/map.h b/lib9p/map.h
index 458fe74..9d4d4af 100644
--- a/lib9p/map.h
+++ b/lib9p/map.h
@@ -109,3 +109,8 @@ static bool MAP_METHOD(NAME,del)(struct NAME *m, KEY_T k) {
#undef KEY_T
#undef VAL_T
#undef CAP
+
+/* Keep the linter happy. */
+#ifndef _LIB9P_MAP_H_
+#define _LIB9P_MAP_H_
+#endif /* _LIB9P_MAP_H_ */
diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h
index 458e74e..6edc4df 100644
--- a/libcr/include/libcr/coroutine.h
+++ b/libcr/include/libcr/coroutine.h
@@ -23,8 +23,8 @@
* See also: coroutine_chan.h is a 1-way channel system built on top
* of coroutine.{h,c}.
*/
-#ifndef _COROUTINE_H_
-#define _COROUTINE_H_
+#ifndef _LIBCR_COROUTINE_H_
+#define _LIBCR_COROUTINE_H_
#include <stddef.h> /* for size_t */
#include <stdbool.h> /* for bool */
@@ -176,4 +176,4 @@ struct cr_cid_info {
void cr_cid_info(cid_t cid, struct cr_cid_info *ret);
-#endif /* _COROUTINE_H_ */
+#endif /* _LIBCR_COROUTINE_H_ */
diff --git a/libcr_ipc/include/libcr_ipc/_linkedlist.h b/libcr_ipc/include/libcr_ipc/_linkedlist.h
index be1b293..b2a94f0 100644
--- a/libcr_ipc/include/libcr_ipc/_linkedlist.h
+++ b/libcr_ipc/include/libcr_ipc/_linkedlist.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _COROUTINE__LINKEDLIST_H_
-#define _COROUTINE__LINKEDLIST_H_
+#ifndef _LIBCR_IPC__LINKEDLIST_H_
+#define _LIBCR_IPC__LINKEDLIST_H_
#include <assert.h>
@@ -105,4 +105,4 @@
_cr_ipc_dll_remove(root, (root)->front); \
} while(0)
-#endif /* _COROUTINE__LINKEDLIST_H_ */
+#endif /* _LIBCR_IPC__LINKEDLIST_H_ */
diff --git a/libcr_ipc/include/libcr_ipc/chan.h b/libcr_ipc/include/libcr_ipc/chan.h
index 0b45752..ec626be 100644
--- a/libcr_ipc/include/libcr_ipc/chan.h
+++ b/libcr_ipc/include/libcr_ipc/chan.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _COROUTINE_CHAN_H_
-#define _COROUTINE_CHAN_H_
+#ifndef _LIBCR_IPC_CHAN_H_
+#define _LIBCR_IPC_CHAN_H_
#include <stdbool.h> /* for bool */
#include <stddef.h> /* for size_t */
@@ -152,4 +152,4 @@ static inline void _cr_chan_xfer(enum _cr_chan_waiter_typ self_typ, struct _cr_c
}
}
-#endif /* _COROUTINE_CHAN_H_ */
+#endif /* _LIBCR_IPC_CHAN_H_ */
diff --git a/libcr_ipc/include/libcr_ipc/mutex.h b/libcr_ipc/include/libcr_ipc/mutex.h
index eb1ecb1..1cc2e61 100644
--- a/libcr_ipc/include/libcr_ipc/mutex.h
+++ b/libcr_ipc/include/libcr_ipc/mutex.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _COROUTINE_MUTEX_H_
-#define _COROUTINE_MUTEX_H_
+#ifndef _LIBCR_IPC_MUTEX_H_
+#define _LIBCR_IPC_MUTEX_H_
#include <stdbool.h> /* for bool */
@@ -74,4 +74,4 @@ static inline void cr_mutex_unlock(cr_mutex_t *mu) {
mu->locked = false;
}
-#endif /* _COROUTINE_MUTEX_H_ */
+#endif /* _LIBCR_IPC_MUTEX_H_ */
diff --git a/libcr_ipc/include/libcr_ipc/rpc.h b/libcr_ipc/include/libcr_ipc/rpc.h
index 9c9c0d5..25c12d6 100644
--- a/libcr_ipc/include/libcr_ipc/rpc.h
+++ b/libcr_ipc/include/libcr_ipc/rpc.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _COROUTINE_RPC_H_
-#define _COROUTINE_RPC_H_
+#ifndef _LIBCR_IPC_RPC_H_
+#define _LIBCR_IPC_RPC_H_
#include <stdbool.h> /* for bool */
@@ -157,4 +157,4 @@
cr_yield(); \
}
-#endif /* _COROUTINE_RPC_H_ */
+#endif /* _LIBCR_IPC_RPC_H_ */
diff --git a/libcr_ipc/include/libcr_ipc/select.h b/libcr_ipc/include/libcr_ipc/select.h
index 94b7643..3daffc2 100644
--- a/libcr_ipc/include/libcr_ipc/select.h
+++ b/libcr_ipc/include/libcr_ipc/select.h
@@ -12,8 +12,8 @@
#include <libcr_ipc/chan.h>
-#ifndef _COROUTINE_SELECT_H_
-#define _COROUTINE_SELECT_H_
+#ifndef _LIBCR_IPC_SELECT_H_
+#define _LIBCR_IPC_SELECT_H_
/* arguments ******************************************************************/
@@ -221,4 +221,4 @@ static inline size_t _cr_select_l(struct cr_select_arg first_arg, ...) {
return cr_select_v(arg_cnt, arg_vec);
}
-#endif /* _COROUTINE_SELECT_H_ */
+#endif /* _LIBCR_IPC_SELECT_H_ */
diff --git a/libcr_ipc/include/libcr_ipc/sema.h b/libcr_ipc/include/libcr_ipc/sema.h
index aa749f9..ca2167f 100644
--- a/libcr_ipc/include/libcr_ipc/sema.h
+++ b/libcr_ipc/include/libcr_ipc/sema.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _COROUTINE_SEMA_H_
-#define _COROUTINE_SEMA_H_
+#ifndef _LIBCR_IPC_SEMA_H_
+#define _LIBCR_IPC_SEMA_H_
#include <libcr/coroutine.h> /* for cid_t, cr_unpause(), cr_pause_and_yield() */
@@ -88,4 +88,4 @@ static inline void cr_sema_wait(cr_sema_t *sema) {
}
}
-#endif /* _COROUTINE_SEMA_H_ */
+#endif /* _LIBCR_IPC_SEMA_H_ */
diff --git a/libusb/include/libusb/usb_common.h b/libusb/include/libusb/usb_common.h
index 7a57c7c..a57abb5 100644
--- a/libusb/include/libusb/usb_common.h
+++ b/libusb/include/libusb/usb_common.h
@@ -4,8 +4,8 @@
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
-#ifndef _USB_COMMON_H_
-#define _USB_COMMON_H_
+#ifndef _LIBUSB_USB_COMMON_H_
+#define _LIBUSB_USB_COMMON_H_
#include <libcr/coroutine.h>
@@ -56,4 +56,4 @@ uint8_t usb_add_config(uint8_t iConfiguration, uint8_t bmAttributes, uint8_t bMa
*/
uint8_t usb_add_interface(uint8_t cfg_num, uint16_t ifc_len, uint8_t *ifc_dat);
-#endif /* _USB_COMMON_H_ */
+#endif /* _LIBUSB_USB_COMMON_H_ */