Skip to contentSkip to conversation

selftest/net: Fix uninit val warning in tcp_mmap.c.

PATCH In review Kuniyuki Iwashima 2 participants 3 messages Apr 5, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftest/net: Fix uninit val warning in tcp_mmap.c.

Commit 5c5945dc695c ("selftests/net: Add SHA256 computation over data sent in tcp_mmap") forgot to initialise a local var.

  $ make -s -C tools/testing/selftests/net
  tcp_mmap.c: In function ‘child_thread’:
  tcp_mmap.c:211:61: warning: ‘lu’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    211 |                         zc.length = min(chunk_size, FILE_SZ - lu);
        |                                                             ^
Fixes 5c5945dc695c ("selftests/net: Add SHA256 computation over data sent in tcp_mmap")

---
Note that the cited commit is not merged in net.git.

---
 tools/testing/selftests/net/tcp_mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/tcp_mmap.c +1 -1
index 607cc9ad8d1b..1056e37f4d98 100644
@@ -168,7 +168,7 @@ void *child_thread(void *arg)
 	double throughput;
 	struct rusage ru;
 	size_t buffer_sz;
-	int lu, fd;
+	int lu = 0, fd;
 
 	fd = (int)(unsigned long)arg;
 
Signature · 1 line
2.30.2
#1 lore raw
Quoted 32 lines · Kuniyuki Iwashima

Commit 5c5945dc695c ("selftests/net: Add SHA256 computation over data sent in tcp_mmap") forgot to initialise a local var.

  $ make -s -C tools/testing/selftests/net
  tcp_mmap.c: In function ‘child_thread’:
  tcp_mmap.c:211:61: warning: ‘lu’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    211 |                         zc.length = min(chunk_size, FILE_SZ - lu);
        |                                                             ^
Fixes 5c5945dc695c ("selftests/net: Add SHA256 computation over data sent in tcp_mmap")

---
Note that the cited commit is not merged in net.git.

---
 tools/testing/selftests/net/tcp_mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/tcp_mmap.c +1 -2
index 607cc9ad8d1b..1056e37f4d98 100644
@@ -168,7 +168,7 @@ void *child_thread(void *arg)
        double throughput;
        struct rusage ru;
        size_t buffer_sz;
-       int lu, fd;
+       int lu = 0, fd;
 
        fd = (int)(unsigned long)arg;
 
--
Quoted 2 lines

2.30.2

This is not the right fix. I sent it yesterday, not sure if you have seen it ?

#2 lore raw
From:   Eric Dumazet <[email protected]>
Date:   Wed, 5 Apr 2023 09:05:38 +0200
Quoted 30 lines · Kuniyuki Iwashima
Quoted 29 lines

Commit 5c5945dc695c ("selftests/net: Add SHA256 computation over data sent in tcp_mmap") forgot to initialise a local var.

  $ make -s -C tools/testing/selftests/net
  tcp_mmap.c: In function ‘child_thread’:
  tcp_mmap.c:211:61: warning: ‘lu’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    211 |                         zc.length = min(chunk_size, FILE_SZ - lu);
        |                                                             ^
Fixes 5c5945dc695c ("selftests/net: Add SHA256 computation over data sent in tcp_mmap")

---
Note that the cited commit is not merged in net.git.

---
 tools/testing/selftests/net/tcp_mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/tcp_mmap.c +1 -1
index 607cc9ad8d1b..1056e37f4d98 100644
@@ -168,7 +168,7 @@ void *child_thread(void *arg)
        double throughput;
        struct rusage ru;
        size_t buffer_sz;
-       int lu, fd;
+       int lu = 0, fd;
 
Quoted 7 lines
Quoted 5 lines
tools/testing/selftests/net/tcp_mmap.c +0 -1
        fd = (int)(unsigned long)arg;
 
--

2.30.2

This is not the right fix. I sent it yesterday, not sure if you have seen it ?

Yes, I missed that.
Sorry for noise and thank you for your fix!