From: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
To: <kuhn.chenqun@huawei.com>
Cc: <qemu-devel@nongnu.org>, <pbonzini@redhat.com>,
<zhang.zhanghailiang@huawei.com>, <qemu-trivial@nongnu.org>
Subject: Re: [PATCH] contrib/elf2dmp: prevent uninitialized warning
Date: Thu, 5 Mar 2020 21:59:02 +0300 [thread overview]
Message-ID: <20200305215902.24bbe6ce@phystech.edu> (raw)
In-Reply-To: <20200207041601.89668-1-kuhn.chenqun@huawei.com>
On Fri, 7 Feb 2020 12:16:01 +0800
<kuhn.chenqun@huawei.com> wrote:
> 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);
Hi!
I suppose the problem is in your compiler, because kdbg_decode() is
only used when KdpDataBlockEncoded is already initialized by
SYM_RESOLVE().
--
Viktor Prutyanov
WARNING: multiple messages have this Message-ID (diff)
From: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
To: <kuhn.chenqun@huawei.com>
Cc: qemu-trivial@nongnu.org, pbonzini@redhat.com,
qemu-devel@nongnu.org, zhang.zhanghailiang@huawei.com
Subject: Re: [PATCH] contrib/elf2dmp: prevent uninitialized warning
Date: Thu, 5 Mar 2020 21:59:02 +0300 [thread overview]
Message-ID: <20200305215902.24bbe6ce@phystech.edu> (raw)
In-Reply-To: <20200207041601.89668-1-kuhn.chenqun@huawei.com>
On Fri, 7 Feb 2020 12:16:01 +0800
<kuhn.chenqun@huawei.com> wrote:
> 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);
Hi!
I suppose the problem is in your compiler, because kdbg_decode() is
only used when KdpDataBlockEncoded is already initialized by
SYM_RESOLVE().
--
Viktor Prutyanov
next prev parent reply other threads:[~2020-03-05 19:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 4:16 [PATCH] contrib/elf2dmp: prevent uninitialized warning kuhn.chenqun
2020-02-07 4:16 ` kuhn.chenqun
2020-03-05 18:59 ` Viktor Prutyanov [this message]
2020-03-05 18:59 ` Viktor Prutyanov
2020-03-06 2:18 ` Chenqun (kuhn)
2020-03-06 2:18 ` Chenqun (kuhn)
2020-03-06 11:47 ` Viktor Prutyanov
2020-03-07 7:00 ` Chenqun (kuhn)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200305215902.24bbe6ce@phystech.edu \
--to=viktor.prutyanov@phystech.edu \
--cc=kuhn.chenqun@huawei.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=zhang.zhanghailiang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.