ila: fix array overflow warning
Subsystems (2)
PATCH 1/1 ila: fix array overflow warning
Aliasing a 64 bit value seems to confuse Gcc 12.2.
ipila.c:57:32: warning: ‘addr’ may be used uninitialized [-Wmaybe-uninitialized]
Use a union instead.
Signed-off-by Stephen Hemminger <[email protected]>
--- ip/ipila.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
ip/ipila.c +5 -2
@@ -47,14 +47,17 @@ static int genl_family = -1;static void print_addr64 (__u64 addr,char *buff,size_t len) { -__u16 *words = (__u16 *)&addr; +union { +__u64 id64; +__u16 words[4 ]; + } id = { .id64 = addr };__u16 v;int i, ret;size_t written =0 ;char *sep =":" ;for (i =0 ; i <4 ; i++) { - v =ntohs (words[i]); + v =ntohs (id.words[i]);if (i ==3 ) sep ="" ;
Signature · 1 line
2.39.2
Quoted 6 lines · Stephen Hemminger
Aliasing a 64 bit value seems to confuse Gcc 12.2.
ipila.c:57:32: warning: ‘addr’ may be used uninitialized [-Wmaybe-uninitialized]Use a union instead.
Signed-off-by Stephen Hemminger <[email protected]>
Reviewed-by Petr Machata <[email protected]>
Quoted 28 lines
--- ip/ipila.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)ip/ipila.c +5
-2@@ -47,14 +47,17 @@ static int genl_family = -1;static void print_addr64 (__u64 addr,char *buff,size_t len) { -__u16 *words = (__u16 *)&addr; +union { +__u64 id64; +__u16 words[4 ]; + } id = { .id64 = addr };__u16 v;int i, ret;size_t written =0 ;char *sep =":" ;for (i =0 ; i <4 ; i++) { - v =ntohs (words[i]); + v =ntohs (id.words[i]);if (i ==3 ) sep ="" ;
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Hello:
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Quoted 8 lines · On Wed, 4 Oct 2023 10:02:58 -0700 you wrote:
Aliasing a 64 bit value seems to confuse Gcc 12.2.
ipila.c:57:32: warning: ‘addr’ may be used uninitialized [-Wmaybe-uninitialized]Use a union instead.
Signed-off-by Stephen Hemminger <[email protected]>[...]
Here is the summary with links:
- [iproute2] ila: fix array overflow warning
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=beb5d379e19f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html