* [PATCH iproute2 0/3] compiler warning fixes
@ 2026-08-23 23:51 Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 1/3] json_print: fix Gcc-17 warnings Stephen Hemminger
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Stephen Hemminger @ 2026-08-23 23:51 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Three small patches that fix warnings when iproute2 is built with latest
GCC-17 and/or Clang-21.
Stephen Hemminger (3):
json_print: fix Gcc-17 warnings
lib: fix warning from ll_addr_a2n
tc/f_u32: fix const strchr() warning
include/json_print.h | 4 ++--
lib/ll_addr.c | 52 +++++++++++++++++++++++---------------------
tc/f_u32.c | 6 +++--
3 files changed, 33 insertions(+), 29 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH iproute2 1/3] json_print: fix Gcc-17 warnings
2026-08-23 23:51 [PATCH iproute2 0/3] compiler warning fixes Stephen Hemminger
@ 2026-08-23 23:51 ` Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 2/3] lib: fix warning from ll_addr_a2n Stephen Hemminger
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2026-08-23 23:51 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Lastest version of Gcc and Clang warn about value of 2 in
logical operator. Example:
warning: use of logical ‘&&’ with constant operand ‘2’ [-Wconstant-logical-operand]
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
include/json_print.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/json_print.h b/include/json_print.h
index 6a458189..79d8d4ff 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -15,8 +15,8 @@
#include "json_writer.h"
#include "color.h"
-#define _IS_JSON_CONTEXT(type) (is_json_context() && (type & PRINT_JSON || type & PRINT_ANY))
-#define _IS_FP_CONTEXT(type) (!is_json_context() && (type & PRINT_FP || type & PRINT_ANY))
+#define _IS_JSON_CONTEXT(type) (is_json_context() && !!((type) & (PRINT_JSON | PRINT_ANY)))
+#define _IS_FP_CONTEXT(type) (!is_json_context() && !!((type) & (PRINT_FP | PRINT_ANY)))
json_writer_t *get_json_writer(void);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH iproute2 2/3] lib: fix warning from ll_addr_a2n
2026-08-23 23:51 [PATCH iproute2 0/3] compiler warning fixes Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 1/3] json_print: fix Gcc-17 warnings Stephen Hemminger
@ 2026-08-23 23:51 ` Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 3/3] tc/f_u32: fix const strchr() warning Stephen Hemminger
2026-08-25 4:10 ` [PATCH iproute2 0/3] compiler warning fixes patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2026-08-23 23:51 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Recent versions of strchr() propogate const char *.
This triggers warnings about lost of const.
Resolve this by reworking the loop parsing hex values.
This also adds checking for garbage after the hex value.
Also:
- arg is no longer modified
- Trailing garbage ("00:11:zz", "00:11:") are now rejected
- An address longer than len bytes now fails
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/ll_addr.c | 52 ++++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/lib/ll_addr.c b/lib/ll_addr.c
index 7a9eb3a4..851a5be0 100644
--- a/lib/ll_addr.c
+++ b/lib/ll_addr.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
@@ -45,8 +46,12 @@ const char *ll_addr_n2a(const unsigned char *addr, int alen, int type,
/*NB: lladdr is char * (rather than u8 *) because sa_data is char * (1003.1g) */
int ll_addr_a2n(char *lladdr, int len, const char *arg)
{
+ const char *cp;
+ int i;
+
if (strchr(arg, '.')) {
inet_prefix pfx;
+
if (get_addr_1(&pfx, arg, AF_INET)) {
fprintf(stderr, "\"%s\" is invalid lladdr.\n", arg);
return -1;
@@ -55,31 +60,28 @@ int ll_addr_a2n(char *lladdr, int len, const char *arg)
return -1;
memcpy(lladdr, pfx.data, 4);
return 4;
- } else {
- int i;
+ }
- for (i = 0; i < len; i++) {
- int temp;
- char *cp = strchr(arg, ':');
- if (cp) {
- *cp = 0;
- cp++;
- }
- if (sscanf(arg, "%x", &temp) != 1) {
- fprintf(stderr, "\"%s\" is invalid lladdr.\n",
- arg);
- return -1;
- }
- if (temp < 0 || temp > 255) {
- fprintf(stderr, "\"%s\" is invalid lladdr.\n",
- arg);
- return -1;
- }
- lladdr[i] = temp;
- if (!cp)
- break;
- arg = cp;
- }
- return i + 1;
+ for (i = 0, cp = arg; i < len; i++) {
+ unsigned long val;
+ char *endp;
+
+ if (!isxdigit(*cp))
+ goto invalid;
+
+ val = strtoul(cp, &endp, 16);
+ if (val > 255)
+ goto invalid;
+
+ lladdr[i] = val;
+
+ if (*endp == '\0')
+ return i + 1;
+ if (*endp != ':')
+ goto invalid;
+ cp = endp + 1;
}
+invalid:
+ fprintf(stderr, "\"%s\" is invalid lladdr.\n", arg);
+ return -1;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH iproute2 3/3] tc/f_u32: fix const strchr() warning
2026-08-23 23:51 [PATCH iproute2 0/3] compiler warning fixes Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 1/3] json_print: fix Gcc-17 warnings Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 2/3] lib: fix warning from ll_addr_a2n Stephen Hemminger
@ 2026-08-23 23:51 ` Stephen Hemminger
2026-08-25 4:10 ` [PATCH iproute2 0/3] compiler warning fixes patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2026-08-23 23:51 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Newer GCC propogates const char across strchr() which
requires spliting temp variable.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/f_u32.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tc/f_u32.c b/tc/f_u32.c
index 088d744e..ae285146 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -41,13 +41,15 @@ static void explain(void)
static int get_u32_handle(__u32 *handle, const char *str)
{
__u32 htid = 0, hash = 0, nodeid = 0;
- char *tmp = strchr(str, ':');
+ const char *colon = strchr(str, ':');
+ char *tmp;
- if (tmp == NULL) {
+ if (colon == NULL) {
if (memcmp("0x", str, 2) == 0)
return get_u32(handle, str, 16);
return -1;
}
+
htid = strtoul(str, &tmp, 16);
if (tmp == str && *str != ':' && *str != 0)
return -1;
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2 0/3] compiler warning fixes
2026-08-23 23:51 [PATCH iproute2 0/3] compiler warning fixes Stephen Hemminger
` (2 preceding siblings ...)
2026-08-23 23:51 ` [PATCH iproute2 3/3] tc/f_u32: fix const strchr() warning Stephen Hemminger
@ 2026-08-25 4:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-25 4:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
Hello:
This series was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:
On Sun, 23 Aug 2026 16:51:30 -0700 you wrote:
> Three small patches that fix warnings when iproute2 is built with latest
> GCC-17 and/or Clang-21.
>
> Stephen Hemminger (3):
> json_print: fix Gcc-17 warnings
> lib: fix warning from ll_addr_a2n
> tc/f_u32: fix const strchr() warning
>
> [...]
Here is the summary with links:
- [iproute2,1/3] json_print: fix Gcc-17 warnings
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=9361f61abb6d
- [iproute2,2/3] lib: fix warning from ll_addr_a2n
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=5faf18f672c1
- [iproute2,3/3] tc/f_u32: fix const strchr() warning
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=21a61425cb9a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-25 4:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-23 23:51 [PATCH iproute2 0/3] compiler warning fixes Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 1/3] json_print: fix Gcc-17 warnings Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 2/3] lib: fix warning from ll_addr_a2n Stephen Hemminger
2026-08-23 23:51 ` [PATCH iproute2 3/3] tc/f_u32: fix const strchr() warning Stephen Hemminger
2026-08-25 4:10 ` [PATCH iproute2 0/3] compiler warning fixes patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox