qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] contrib/elf2dmp: prevent uninitialized warning
@ 2020-02-07  4:16 kuhn.chenqun
  2020-03-05 18:59 ` Viktor Prutyanov
  0 siblings, 1 reply; 5+ messages in thread
From: kuhn.chenqun @ 2020-02-07  4:16 UTC (permalink / raw)
  To: qemu-devel, viktor.prutyanov, pbonzini
  Cc: qemu-trivial, Chen Qun, zhang.zhanghailiang

From: Chen Qun <kuhn.chenqun@huawei.com>

Fix compilation warnings:
contrib/elf2dmp/main.c:66:17: warning: ‘KdpDataBlockEncoded’ may be used
 uninitialized in this function [-Wmaybe-uninitialized]
         block = __builtin_bswap64(block ^ kdbe) ^ kwa;
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
contrib/elf2dmp/main.c:78:24: note: ‘KdpDataBlockEncoded’ was declared here
     uint64_t kwn, kwa, KdpDataBlockEncoded;
                        ^~~~~~~~~~~~~~~~~~~

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
 contrib/elf2dmp/main.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
index 9a2dbc2902..203b9e6d04 100644
--- a/contrib/elf2dmp/main.c
+++ b/contrib/elf2dmp/main.c
@@ -76,6 +76,7 @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb,
     DBGKD_DEBUG_DATA_HEADER64 kdbg_hdr;
     bool decode = false;
     uint64_t kwn, kwa, KdpDataBlockEncoded;
+    uint64_t KiWaitNever, KiWaitAlways;
 
     if (va_space_rw(vs,
                 KdDebuggerDataBlock + offsetof(KDDEBUGGER_DATA64, Header),
@@ -84,21 +85,19 @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb,
         return NULL;
     }
 
-    if (memcmp(&kdbg_hdr.OwnerTag, OwnerTag, sizeof(OwnerTag))) {
-        uint64_t KiWaitNever, KiWaitAlways;
-
-        decode = true;
+    if (!SYM_RESOLVE(KernBase, pdb, KiWaitNever) ||
+            !SYM_RESOLVE(KernBase, pdb, KiWaitAlways) ||
+            !SYM_RESOLVE(KernBase, pdb, KdpDataBlockEncoded)) {
+        return NULL;
+    }
 
-        if (!SYM_RESOLVE(KernBase, pdb, KiWaitNever) ||
-                !SYM_RESOLVE(KernBase, pdb, KiWaitAlways) ||
-                !SYM_RESOLVE(KernBase, pdb, KdpDataBlockEncoded)) {
-            return NULL;
-        }
+    if (va_space_rw(vs, KiWaitNever, &kwn, sizeof(kwn), 0) ||
+            va_space_rw(vs, KiWaitAlways, &kwa, sizeof(kwa), 0)) {
+        return NULL;
+    }
 
-        if (va_space_rw(vs, KiWaitNever, &kwn, sizeof(kwn), 0) ||
-                va_space_rw(vs, KiWaitAlways, &kwa, sizeof(kwa), 0)) {
-            return NULL;
-        }
+    if (memcmp(&kdbg_hdr.OwnerTag, OwnerTag, sizeof(OwnerTag))) {
+        decode = true;
 
         printf("[KiWaitNever] = 0x%016"PRIx64"\n", kwn);
         printf("[KiWaitAlways] = 0x%016"PRIx64"\n", kwa);
-- 
2.23.0




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

end of thread, other threads:[~2020-03-07  7:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-07  4:16 [PATCH] contrib/elf2dmp: prevent uninitialized warning kuhn.chenqun
2020-03-05 18:59 ` Viktor Prutyanov
2020-03-06  2:18   ` Chenqun (kuhn)
2020-03-06 11:47     ` Viktor Prutyanov
2020-03-07  7:00       ` Chenqun (kuhn)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).