From f6a929ebbedc447c81f58b8bb52cf072b6bf1a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 16 Mar 2025 17:01:04 +0100 Subject: [PATCH 1/4] Drop -Wno-unused-result flag All important function results should be and are handled. --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index 3a8b724..30f23d6 100644 --- a/meson.build +++ b/meson.build @@ -48,7 +48,6 @@ c_args = ''' -Wwrite-strings -Wno-unused-parameter -Wno-missing-field-initializers - -Wno-unused-result -Werror=overflow -Werror=sign-compare -Wdate-time From 48537a9dd35823ad9cbe21db848bebce9eeaf478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 16 Mar 2025 17:02:45 +0100 Subject: [PATCH 2/4] Use NULL as 0 pointer constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spotted with the compiler flag -Wzero-as-null-pointer-constant. Do not add this flag though, due to an occurrence in gperf generated code: ../src/netlog/netlog-gperf.gperf: In function ‘netlog_gperf_lookup’: ../src/netlog/netlog-gperf.gperf:38:10: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant] --- src/netlog/netlog-dtls.c | 4 ++-- src/netlog/netlog-tls.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/netlog/netlog-dtls.c b/src/netlog/netlog-dtls.c index ff89e58..eac5deb 100644 --- a/src/netlog/netlog-dtls.c +++ b/src/netlog/netlog-dtls.c @@ -148,10 +148,10 @@ int dtls_connect(DTLSManager *m, SocketAddress *address) { if (cert) { _cleanup_(OPENSSL_freep) void *subject = NULL, *issuer = NULL; - subject = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0); + subject = X509_NAME_oneline(X509_get_subject_name(cert), NULL, 0); log_debug("DTLS: Subject: %s", (char *) subject); - issuer = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0); + issuer = X509_NAME_oneline(X509_get_issuer_name(cert), NULL, 0); log_debug("DTLS: Issuer: %s", (char *) issuer); } else log_debug("DTLS: No certificates."); diff --git a/src/netlog/netlog-tls.c b/src/netlog/netlog-tls.c index 1f72b0c..218baaa 100644 --- a/src/netlog/netlog-tls.c +++ b/src/netlog/netlog-tls.c @@ -147,10 +147,10 @@ int tls_connect(TLSManager *m, SocketAddress *address) { if (cert) { _cleanup_(OPENSSL_freep) void *subject = NULL, *issuer = NULL; - subject = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0); + subject = X509_NAME_oneline(X509_get_subject_name(cert), NULL, 0); log_debug("TLS: SSL Subject: %s", (char *) subject); - issuer = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0); + issuer = X509_NAME_oneline(X509_get_issuer_name(cert), NULL, 0); log_debug("TLS: SSL Issuer: %s", (char *) issuer); } else log_debug("TLS: SSL No certificates."); From 547c2cdb167972f6684d2036f0855f3ce67f7062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 16 Mar 2025 17:03:17 +0100 Subject: [PATCH 3/4] Supply comment in static assert Static asserts without a comment are a language extension. --- src/netlog/netlog-ssl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netlog/netlog-ssl.c b/src/netlog/netlog-ssl.c index d0c4450..3718525 100644 --- a/src/netlog/netlog-ssl.c +++ b/src/netlog/netlog-ssl.c @@ -9,7 +9,7 @@ #include "netlog-dtls.h" #include "netlog-tls.h" -static_assert(offsetof(TLSManager, auth_mode) == offsetof(DTLSManager, auth_mode)); +static_assert(offsetof(TLSManager, auth_mode) == offsetof(DTLSManager, auth_mode), "TLSManager and DTLSManager must be similar"); /* inspired by SSL_set_verify(3) */ int ssl_verify_certificate_validity(int preverify_ok, X509_STORE_CTX *store) { From e8eccaf71625641fbfd92b1bf7a196a9e06ebabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 16 Mar 2025 17:06:47 +0100 Subject: [PATCH 4/4] Annotate non NUL-terminated character array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The lookup table in hexchar() is of the size of its number of elements and thus not implicitly NUL-terminated. Add the nonstring annotation to please GCC 15: ../src/share/hexdecoct.c: In function ‘hexchar’: ../src/share/hexdecoct.c:38:39: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (17 chars into 16 available) [-Wunterminated-string-initialization] 38 | static const char table[16] = "0123456789abcdef"; | ^~~~~~~~~~~~~~~~~~ --- src/share/hexdecoct.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/share/hexdecoct.c b/src/share/hexdecoct.c index 6338533..6f3ec85 100644 --- a/src/share/hexdecoct.c +++ b/src/share/hexdecoct.c @@ -35,6 +35,7 @@ int undecchar(char c) { } char hexchar(int x) { + __attribute__ ((nonstring)) static const char table[16] = "0123456789abcdef"; return table[x & 15];