From patchwork Fri Feb 7 04:16:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Qun X-Patchwork-Id: 11369747 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DD90112B for ; Fri, 7 Feb 2020 04:16:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D01F0222C2 for ; Fri, 7 Feb 2020 04:16:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D01F0222C2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izv4a-0003Ie-MZ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 06 Feb 2020 23:16:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40992) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izv43-0002my-9z for qemu-devel@nongnu.org; Thu, 06 Feb 2020 23:16:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1izv42-0001YG-5M for qemu-devel@nongnu.org; Thu, 06 Feb 2020 23:16:23 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2757 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1izv41-0001Df-QP; Thu, 06 Feb 2020 23:16:22 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0DD36944BA51A879F96E; Fri, 7 Feb 2020 12:16:14 +0800 (CST) Received: from HGHY4C002233111.china.huawei.com (10.133.205.93) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Fri, 7 Feb 2020 12:16:04 +0800 From: To: , , Subject: [PATCH] contrib/elf2dmp: prevent uninitialized warning Date: Fri, 7 Feb 2020 12:16:01 +0800 Message-ID: <20200207041601.89668-1-kuhn.chenqun@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.133.205.93] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.191 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Chen Qun , zhang.zhanghailiang@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Chen Qun 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 Signed-off-by: Chen Qun --- 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);