aboutgitcodebugslistschat
path: root/packet.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-10-13 15:50:29 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-11-07 09:54:56 +0100
commit59722031744e76c5619ed5b46b8aae76b01b32ac (patch)
tree31b76a426bd405718b9a0285283174111c711d2f /packet.c
parent50d46ec847492dbcf6f0b15221188ad439d5e572 (diff)
downloadpasst-59722031744e76c5619ed5b46b8aae76b01b32ac.tar
passt-59722031744e76c5619ed5b46b8aae76b01b32ac.tar.gz
passt-59722031744e76c5619ed5b46b8aae76b01b32ac.tar.bz2
passt-59722031744e76c5619ed5b46b8aae76b01b32ac.tar.lz
passt-59722031744e76c5619ed5b46b8aae76b01b32ac.tar.xz
passt-59722031744e76c5619ed5b46b8aae76b01b32ac.tar.zst
passt-59722031744e76c5619ed5b46b8aae76b01b32ac.zip
log: Enable format warnings
logmsg() takes printf like arguments, but because it's not a built in, the compiler won't generate warnings if the format string and parameters don't match. Enable those by using the format attribute. Strictly speaking this is a gcc extension, but I believe it is also supported by some other common compilers. We already use some other attributes in various places. For now, just use it and we can worry about compilers that don't support it if it comes up. This exposes some warnings from existing callers, both in gcc and in clang-tidy: - Some are straight out bugs, which we correct - It's occasionally useful to invoke the logging functions with an empty string, which gcc objects to, so disable that specific warning in the Makefile - Strictly speaking the C standard requires that the parameter for a %p be a (void *), not some other pointer type. That's only likely to cause problems in practice on weird architectures with different sized representations for pointers to different types. Nonetheless add the casts to make it happy. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/packet.c b/packet.c
index 693e034..9589824 100644
--- a/packet.c
+++ b/packet.c
@@ -43,13 +43,14 @@ void packet_add_do(struct pool *p, size_t len, const char *start,
if (start < p->buf) {
trace("add packet start %p before buffer start %p, %s:%i",
- start, p->buf, func, line);
+ (void *)start, (void *)p->buf, func, line);
return;
}
if (start + len > p->buf + p->buf_size) {
trace("add packet start %p, length: %lu, buffer end %p, %s:%i",
- start, len, p->buf + p->buf_size, func, line);
+ (void *)start, len, (void *)(p->buf + p->buf_size),
+ func, line);
return;
}
@@ -61,7 +62,7 @@ void packet_add_do(struct pool *p, size_t len, const char *start,
#if UINTPTR_MAX == UINT64_MAX
if ((uintptr_t)start - (uintptr_t)p->buf > UINT32_MAX) {
trace("add packet start %p, buffer start %p, %s:%i",
- start, p->buf, func, line);
+ (void *)start, (void *)p->buf, func, line);
return;
}
#endif