summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-05 03:41:44 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-05 21:34:27 -0600
commit8a39cfe7f245bea8b3a458238b694de13c61b88a (patch)
tree9969e8e902bedacdde3ebef0ed7ec6a2f0b23618
parentd291799fc5bb4fa1bde757c1a78646b0dc2551a1 (diff)
SYSTEM headers don't get strict GCC checks, so change them to PUBLIC
-rw-r--r--lib9p/CMakeLists.txt2
-rw-r--r--lib9p/srv.c12
-rw-r--r--lib9p_util/CMakeLists.txt2
-rw-r--r--libcr/CMakeLists.txt2
-rw-r--r--libcr/coroutine.c6
-rw-r--r--libcr_ipc/CMakeLists.txt2
-rw-r--r--libcr_ipc/include/libcr_ipc/chan.h10
-rw-r--r--libcr_ipc/include/libcr_ipc/rpc.h22
-rw-r--r--libcr_ipc/include/libcr_ipc/select.h3
-rw-r--r--libcr_ipc/include/libcr_ipc/sema.h4
-rw-r--r--libdhcp/CMakeLists.txt2
-rw-r--r--libfmt/CMakeLists.txt2
-rw-r--r--libhw_cr/CMakeLists.txt4
-rw-r--r--libhw_generic/CMakeLists.txt2
-rw-r--r--libmisc/CMakeLists.txt2
-rw-r--r--libmisc/include/libmisc/_intercept.h4
-rw-r--r--libmisc/include/libmisc/rand.h4
-rw-r--r--libmisc/tests/test_macro.c1
-rw-r--r--libobj/CMakeLists.txt2
-rw-r--r--libusb/CMakeLists.txt2
20 files changed, 49 insertions, 41 deletions
diff --git a/lib9p/CMakeLists.txt b/lib9p/CMakeLists.txt
index 11a58ba..d433a12 100644
--- a/lib9p/CMakeLists.txt
+++ b/lib9p/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(lib9p INTERFACE)
-target_include_directories(lib9p SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(lib9p PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_sources(lib9p INTERFACE
9p.generated.c
9p.c
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 6e6a91b..12556b0 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -199,7 +199,11 @@ static void respond_error(struct _lib9p_srv_req *req) {
LIB9P_TYP_Rerror, &host,
&net);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
infof("< %v", lo_box_lib9p_msg_Rerror_as_fmt_formatter(&host));
+#pragma GCC diagnostic pop
r = write_Rmsg(req, &net);
if (r < 0)
nonrespond_errorf("write: %s", net_strerror(-r));
@@ -425,7 +429,11 @@ static void handle_message(struct _lib9p_srv_req *ctx) {
enum lib9p_msg_type typ;
lib9p_Tmsg_unmarshal(&ctx->ctx.basectx, ctx->net_bytes,
&typ, host_req);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
infof("> %v", lo_box_lib9p_msg_as_fmt_formatter(&ctx->ctx.basectx, typ, host_req));
+#pragma GCC diagnostic pop
/* Handle it. */
tmessage_handlers[typ](ctx, (void *)host_req, (void *)host_resp);
@@ -439,7 +447,11 @@ static void handle_message(struct _lib9p_srv_req *ctx) {
typ+1, host_resp,
&net_resp))
goto write;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
infof("< %v", lo_box_lib9p_msg_as_fmt_formatter(&ctx->ctx.basectx, typ+1, &host_resp));
+#pragma GCC diagnostic pop
write_Rmsg(ctx, &net_resp);
}
if (host_req)
diff --git a/lib9p_util/CMakeLists.txt b/lib9p_util/CMakeLists.txt
index 4fbdb7a..2e5790e 100644
--- a/lib9p_util/CMakeLists.txt
+++ b/lib9p_util/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(lib9p_util INTERFACE)
-target_include_directories(lib9p_util SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(lib9p_util PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_sources(lib9p_util INTERFACE
static.c
)
diff --git a/libcr/CMakeLists.txt b/libcr/CMakeLists.txt
index 0a4696c..80a4ece 100644
--- a/libcr/CMakeLists.txt
+++ b/libcr/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libcr INTERFACE)
-target_include_directories(libcr SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+target_include_directories(libcr PUBLIC INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_sources(libcr INTERFACE
coroutine.c
)
diff --git a/libcr/coroutine.c b/libcr/coroutine.c
index 33e8141..bf44219 100644
--- a/libcr/coroutine.c
+++ b/libcr/coroutine.c
@@ -424,9 +424,9 @@ static const uint8_t stack_pattern[] = {
#endif
#if CONFIG_COROUTINE_PROTECT_STACK
#define CR_STACK_GUARD_SIZE \
- LM_ROUND_UP(sizeof(stack_pattern), CR_PLAT_STACK_ALIGNMENT)
+ ((size_t)LM_ROUND_UP(sizeof(stack_pattern), CR_PLAT_STACK_ALIGNMENT))
#else
- #define CR_STACK_GUARD_SIZE 0
+ #define CR_STACK_GUARD_SIZE ((size_t)0)
#endif
/* global variables ***********************************************************/
@@ -584,7 +584,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
name, stack_size, CR_STACK_GUARD_SIZE, coroutine_table[child-1].stack_size);
coroutine_table[child-1].stack =
aligned_alloc(CR_PLAT_STACK_ALIGNMENT, coroutine_table[child-1].stack_size);
- infof("... done, stack is [%#zx,%#zx)",
+ infof("... done, stack is [0x%p,0x%p)",
coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE,
coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE + stack_size);
#if CONFIG_COROUTINE_MEASURE_STACK || CONFIG_COROUTINE_PROTECT_STACK
diff --git a/libcr_ipc/CMakeLists.txt b/libcr_ipc/CMakeLists.txt
index 3746584..8545798 100644
--- a/libcr_ipc/CMakeLists.txt
+++ b/libcr_ipc/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libcr_ipc INTERFACE)
-target_include_directories(libcr_ipc SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+target_include_directories(libcr_ipc PUBLIC INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_sources(libcr_ipc INTERFACE
chan.c
select.c
diff --git a/libcr_ipc/include/libcr_ipc/chan.h b/libcr_ipc/include/libcr_ipc/chan.h
index 5b1e583..dafc92d 100644
--- a/libcr_ipc/include/libcr_ipc/chan.h
+++ b/libcr_ipc/include/libcr_ipc/chan.h
@@ -21,7 +21,7 @@
*
* type:
*
- * /**
+ * / **
* * A NAME##_t is a fair unbuffered channel that transports
* * values of type `VAL_T`.
* *
@@ -35,7 +35,7 @@
*
* methods:
*
- * /**
+ * / **
* * NAME##_send(ch, val) sends `val` over `ch`.
* *
* * @runs_in coroutine
@@ -44,7 +44,7 @@
* * /
* void NAME##_send(NAME##_t *ch, VAL_T val);
*
- * /**
+ * / **
* * NAME##_recv(ch) reads and returns a value from ch.
* *
* * @runs_in coroutine
@@ -53,7 +53,7 @@
* * /
* VAL_T NAME##_recv(NAME##_t *ch);
*
- * /**
+ * / **
* * NAME##_can_send(ch) returns whether NAME##_send(ch, val)
* * would run without pausing.
* *
@@ -63,7 +63,7 @@
* * /
* bool NAME##_can_send(NAME##_t *ch);
*
- * /**
+ * / **
* * NAME##_can_recv(ch) returns whether NAME##_recv(ch) would
* * return without pausing.
* *
diff --git a/libcr_ipc/include/libcr_ipc/rpc.h b/libcr_ipc/include/libcr_ipc/rpc.h
index 0ff8bbf..0600399 100644
--- a/libcr_ipc/include/libcr_ipc/rpc.h
+++ b/libcr_ipc/include/libcr_ipc/rpc.h
@@ -20,7 +20,7 @@
*
* type:
*
- * /**
+ * / **
* * A NAME##_t is a fair rpc-channel on which the requester submits a
* * value of type `REQ_T` and the responder responds with a value of
* * type `RESP_T`.
@@ -35,7 +35,7 @@
* * _recv_req() and _send_resp().
* typedef ... NAME##_t;
*
- * /**
+ * / **
* * A NAME##_req_t is handle that wraps a REQ_T and is used to return
* * the response RESP_T to the correct requester. `REQ_T req` is the
* * only public member.
@@ -43,7 +43,7 @@
*
* methods:
*
- * /**
+ * / **
* * NAME##_send_req(ch, req) submits the `req` request over `ch` and
* * returns the response.
* *
@@ -53,7 +53,7 @@
* * /
* RESP_T NAME##_send_req(NAME##_t *ch, REQ_T req);
*
- * /**
+ * / **
* * NAME##_recv_req(ch) reads a request from ch, and returns a
* * NAME##_req_t handle wrapping that request.
* *
@@ -63,7 +63,7 @@
* * /
* NAME##_req_t NAME##_recv_req(NAME##_t *ch);
*
- * /**
+ * / **
* * NAME##_can_recv_req(ch) returns whether NAME##_recv_req(ch)
* * would return without pausing.
* *
@@ -75,7 +75,7 @@
*
* type:
*
- * /**
+ * / **
* * A NAME##_req_t is a handle that wraps a REQ_T, and is a channel
* * that a response may be written to.
* * /
@@ -83,7 +83,7 @@
*
* methods:
*
- * /**
+ * / **
* * cr_rpc_send_resp(req, resp) sends the given response to the given
* * request.
* *
@@ -111,7 +111,7 @@
RESP_T resp; \
_cr_rpc_send_req(&ch->core, \
&req, sizeof(req), \
- &resp, sizeof(resp)); \
+ &resp); \
return resp; \
} \
\
@@ -152,8 +152,8 @@ struct _cr_rpc_requester {
struct _cr_rpc_responder {
_cr_ipc_sll_node;
- /* /* before enqueued | after dequeued */
- /* /* -------------------+-------------------- */
+ /* before enqueued | after dequeued */
+ /* -------------------+-------------------- */
cid_t cid; /* responder cid | requester cid */
void *ptr; /* where to write req | where to write resp */
};
@@ -165,7 +165,7 @@ struct _cr_rpc {
static inline void _cr_rpc_send_req(struct _cr_rpc *ch,
void *req_ptr, size_t req_size,
- void *resp_ptr, size_t resp_size)
+ void *resp_ptr)
{
assert(ch);
assert(req_ptr);
diff --git a/libcr_ipc/include/libcr_ipc/select.h b/libcr_ipc/include/libcr_ipc/select.h
index b845082..0e35351 100644
--- a/libcr_ipc/include/libcr_ipc/select.h
+++ b/libcr_ipc/include/libcr_ipc/select.h
@@ -33,8 +33,6 @@ struct cr_select_arg {
};
#define CR_SELECT_RECV(CH, VALP) ({ \
- assert(CH); \
- assert(VALP); \
/* The _valp indirection is to get the \
* compiler to check that the types are \
* compatible. */ \
@@ -47,7 +45,6 @@ struct cr_select_arg {
}); \
})
#define CR_SELECT_SEND(CH, VAL) ({ \
- assert(CH); \
typeof((CH)->vals[0]) val_lvalue = VAL; \
((struct cr_select_arg){ \
.op = _CR_SELECT_OP_SEND, \
diff --git a/libcr_ipc/include/libcr_ipc/sema.h b/libcr_ipc/include/libcr_ipc/sema.h
index 6db4015..fcabf28 100644
--- a/libcr_ipc/include/libcr_ipc/sema.h
+++ b/libcr_ipc/include/libcr_ipc/sema.h
@@ -84,9 +84,9 @@ static inline void cr_sema_wait(cr_sema_t *sema) {
.cid = cr_getcid(),
};
_cr_ipc_sll_push_to_rear(&sema->waiters, &self);
- if (sema->waiters.front != &self || !sema->cnt)
+ if (sema->waiters.front != &self._cr_ipc_sll_node || !sema->cnt)
cr_pause_and_yield();
- assert(sema->waiters.front == &self && sema->cnt);
+ assert(sema->waiters.front == &self._cr_ipc_sll_node && sema->cnt);
_cr_ipc_sll_pop_from_front(&sema->waiters);
sema->cnt--;
if (sema->cnt && sema->waiters.front)
diff --git a/libdhcp/CMakeLists.txt b/libdhcp/CMakeLists.txt
index 72b0952..dee7cb6 100644
--- a/libdhcp/CMakeLists.txt
+++ b/libdhcp/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libdhcp INTERFACE)
-target_include_directories(libdhcp SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(libdhcp PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_sources(libdhcp INTERFACE
dhcp_client.c
)
diff --git a/libfmt/CMakeLists.txt b/libfmt/CMakeLists.txt
index 1b3a80f..f65d462 100644
--- a/libfmt/CMakeLists.txt
+++ b/libfmt/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libfmt INTERFACE)
-target_include_directories(libfmt SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(libfmt PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_sources(libfmt INTERFACE
libmisc.c
libobj.c
diff --git a/libhw_cr/CMakeLists.txt b/libhw_cr/CMakeLists.txt
index caeac21..ba20b26 100644
--- a/libhw_cr/CMakeLists.txt
+++ b/libhw_cr/CMakeLists.txt
@@ -14,7 +14,7 @@ target_sources(libhw_cr INTERFACE
)
if (PICO_PLATFORM STREQUAL "rp2040")
- target_include_directories(libhw_cr SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/rp2040_include)
+ target_include_directories(libhw_cr PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/rp2040_include)
target_link_libraries(libhw_cr INTERFACE
libcr_ipc
)
@@ -34,7 +34,7 @@ if (PICO_PLATFORM STREQUAL "rp2040")
endif()
if (PICO_PLATFORM STREQUAL "host")
- target_include_directories(libhw_cr SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/host_include)
+ target_include_directories(libhw_cr PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/host_include)
target_sources(libhw_cr INTERFACE
host_util.c
host_alarmclock.c
diff --git a/libhw_generic/CMakeLists.txt b/libhw_generic/CMakeLists.txt
index 5a6014b..603f30b 100644
--- a/libhw_generic/CMakeLists.txt
+++ b/libhw_generic/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libhw_generic INTERFACE)
-target_include_directories(libhw_generic SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(libhw_generic PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(libhw_generic INTERFACE
libmisc
libobj
diff --git a/libmisc/CMakeLists.txt b/libmisc/CMakeLists.txt
index 70ec691..4599ead 100644
--- a/libmisc/CMakeLists.txt
+++ b/libmisc/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libmisc INTERFACE)
-target_include_directories(libmisc SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(libmisc PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_sources(libmisc INTERFACE
assert.c
intercept.c
diff --git a/libmisc/include/libmisc/_intercept.h b/libmisc/include/libmisc/_intercept.h
index ab76857..a264144 100644
--- a/libmisc/include/libmisc/_intercept.h
+++ b/libmisc/include/libmisc/_intercept.h
@@ -13,7 +13,7 @@
* own `__lm_` wrappers that GCC/glibc won't interfere with.
*/
-[[format(printf, 1, 2)]]
+[[gnu::format(printf, 1, 2)]]
int __lm_printf(const char *format, ...);
[[noreturn]] void __lm_abort(void);
@@ -21,7 +21,7 @@ int __lm_printf(const char *format, ...);
/* __lm_light_printf is expected to have less stack use than regular
* __lm_printf, if possible. */
-[[format(printf, 1, 2)]]
+[[gnu::format(printf, 1, 2)]]
int __lm_light_printf(const char *format, ...);
#endif /* _LIBMISC__INTERCEPT_H_ */
diff --git a/libmisc/include/libmisc/rand.h b/libmisc/include/libmisc/rand.h
index 8072841..bb1ec0b 100644
--- a/libmisc/include/libmisc/rand.h
+++ b/libmisc/include/libmisc/rand.h
@@ -29,14 +29,14 @@ static inline uint64_t rand_uint63n(uint64_t cnt) {
uint64_t fair_cnt = ((UINT64_C(1)<<62) / cnt) * cnt;
uint64_t rnd;
do {
- rnd = (random() << 31) | random();
+ rnd = (((uint64_t)random()) << 31) | random();
} while (rnd >= fair_cnt);
return rnd % cnt;
} else if (cnt <= UINT64_C(1)<<63) {
uint64_t fair_cnt = ((UINT64_C(1)<<63) / cnt) * cnt;
uint64_t rnd;
do {
- rnd = (random() << 62) | (random() << 31) | random();
+ rnd = (((uint64_t)random()) << 62) | (((uint64_t)random()) << 31) | random();
} while (rnd >= fair_cnt);
return rnd % cnt;
}
diff --git a/libmisc/tests/test_macro.c b/libmisc/tests/test_macro.c
index 69655d1..1320eb3 100644
--- a/libmisc/tests/test_macro.c
+++ b/libmisc/tests/test_macro.c
@@ -27,7 +27,6 @@ int main() {
/* ... */
test_assert(LM_NEXT_POWER_OF_2(0x8000000000000000-1) == 0x8000000000000000);
/* Valid up to 0x8000000000000000-1 = (1<<63)-1 */
- test_assert(LM_NEXT_POWER_OF_2(0x8000000000000000) == 0); /* :( */
printf("== LM_FLOORLOG2 ===========================================\n");
/* valid down to 1. */
diff --git a/libobj/CMakeLists.txt b/libobj/CMakeLists.txt
index 1cc552c..e4d8095 100644
--- a/libobj/CMakeLists.txt
+++ b/libobj/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libobj INTERFACE)
-target_include_directories(libobj SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(libobj PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(libobj INTERFACE
libmisc
)
diff --git a/libusb/CMakeLists.txt b/libusb/CMakeLists.txt
index 012ab71..9be44ac 100644
--- a/libusb/CMakeLists.txt
+++ b/libusb/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libusb INTERFACE)
-target_include_directories(libusb SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+target_include_directories(libusb PUBLIC INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_sources(libusb INTERFACE
usb_common.c
)