libguestfs/SOURCES/0007-cat-Fix-GCC-10-warning.patch

35 lines
1.2 KiB
Diff
Raw Normal View History

From 93422725a0a8248d97b67cdbc20e065f5164e089 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 6 Feb 2020 10:27:48 +0000
Subject: [PATCH] cat: Fix GCC 10 warning.
I believe this warning is bogus, but simply initializing the local
variable is enough to avoid it.
log.c: In function 'do_log':
log.c:390:7: error: 'comm_len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
390 | printf (" %.*s", (int) comm_len, comm);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(cherry picked from commit 4e199494c41d3240aa5c0708887b7a7513c6b6f2)
---
cat/log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cat/log.c b/cat/log.c
index 25107e25f..f8a5c85f2 100644
--- a/cat/log.c
+++ b/cat/log.c
@@ -337,7 +337,7 @@ do_log_journal (void)
while ((r = guestfs_journal_next (g)) > 0) {
CLEANUP_FREE_XATTR_LIST struct guestfs_xattr_list *xattrs = NULL;
const char *priority_str, *identifier, *comm, *pid, *message;
- size_t priority_len, identifier_len, comm_len, pid_len, message_len;
+ size_t priority_len, identifier_len, comm_len = 0, pid_len, message_len;
int priority = LOG_INFO;
int64_t ts;
--
2.18.4