public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 1/2] Possible uninitialized 'last' variable in usdt_copyin_data()
@ 2025-08-12 22:46 eugene.loh
  2025-08-12 22:46 ` [PATCH 2/2] Use a consistent type for dtrace_consume() eugene.loh
  2025-08-15 15:25 ` [PATCH 1/2] Possible uninitialized 'last' variable in usdt_copyin_data() Kris Van Hees
  0 siblings, 2 replies; 6+ messages in thread
From: eugene.loh @ 2025-08-12 22:46 UTC (permalink / raw)
  To: dtrace, dtrace-devel

From: Eugene Loh <eugene.loh@oracle.com>

Some compilers warn:

libcommon/usdt_parser.c: In function ‘usdt_copyin_data’:
libcommon/usdt_parser.c:191:15: warning:
   ‘last’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    last->next = blk;
    ~~~~~~~~~~~^~~~~

Change the "if" check to make it easier for compilers to recognize
that "last" will be initialized (and non-NULL even!).

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
 libcommon/usdt_parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcommon/usdt_parser.c b/libcommon/usdt_parser.c
index 864198098..d8cb9b7ba 100644
--- a/libcommon/usdt_parser.c
+++ b/libcommon/usdt_parser.c
@@ -163,7 +163,7 @@ usdt_destroy_data(usdt_data_t *data)
 usdt_data_t *
 usdt_copyin_data(int in, int out, int *ok)
 {
-	usdt_data_t *first = NULL, *last;
+	usdt_data_t *first = NULL, *last = NULL;
 	size_t cnt;
 
 	*ok = 1;
@@ -185,7 +185,7 @@ usdt_copyin_data(int in, int out, int *ok)
 		if ((blk = usdt_copyin_block(in, out, ok)) == NULL)
 			goto err;
 
-		if (first == NULL)
+		if (last == NULL)
 			first = last = blk;
 		else {
 			last->next = blk;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-15 17:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 22:46 [PATCH 1/2] Possible uninitialized 'last' variable in usdt_copyin_data() eugene.loh
2025-08-12 22:46 ` [PATCH 2/2] Use a consistent type for dtrace_consume() eugene.loh
2025-08-15 15:35   ` [DTrace-devel] " Kris Van Hees
2025-08-15 15:25 ` [PATCH 1/2] Possible uninitialized 'last' variable in usdt_copyin_data() Kris Van Hees
2025-08-15 17:12   ` Eugene Loh
2025-08-15 17:50     ` Kris Van Hees

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox