From: Paolo Bonzini <pbonzini@redhat.com>
To: "Rustad, Mark D" <mark.d.rustad@intel.com>
Cc: "Kirsher, Jeffrey T" <jeffrey.t.kirsher@intel.com>,
"gleb@kernel.org" <gleb@kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH 3/4] x86/kvm: Resolve shadow warnings in macro expansion
Date: Sat, 26 Jul 2014 09:34:42 +0200 [thread overview]
Message-ID: <53D35A12.9090404@redhat.com> (raw)
In-Reply-To: <267ADA87-C1E0-4E13-BB7E-266EBA61E9A1@intel.com>
Il 25/07/2014 19:18, Rustad, Mark D ha scritto:
> On Jul 25, 2014, at 7:06 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>> Il 25/07/2014 15:27, Jeff Kirsher ha scritto:
>>> From: Mark Rustad <mark.d.rustad@intel.com>
>>>
>>> Resolve shadow warnings that appear in W=2 builds. In this case,
>>> a macro declared an inner local variable with the same name as an
>>> outer one. This can be a serious hazard in the event that the outer
>>> variable is ever passed as a parameter, as the inner variable will
>>> be referenced instead of what was intended. This macro doesn't have
>>> any parameters - at this time - but prepend an _ to all of the
>>> macro-declared variables as is the custom, to resolve the warnings
>>> and eliminate any future hazard.
>>>
>>> Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
>>> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>>> ---
>>> arch/x86/kvm/mmutrace.h | 24 ++++++++++++------------
>>> 1 file changed, 12 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/mmutrace.h b/arch/x86/kvm/mmutrace.h
>>> index 9d2e0ff..2d8d00c 100644
>>> --- a/arch/x86/kvm/mmutrace.h
>>> +++ b/arch/x86/kvm/mmutrace.h
>>> @@ -22,26 +22,26 @@
>>> __entry->unsync = sp->unsync;
>>>
>>> #define KVM_MMU_PAGE_PRINTK() ({ \
>>> - const char *ret = p->buffer + p->len; \
>>> - static const char *access_str[] = { \
>>> + const char *_ret = p->buffer + p->len; \
>>> + static const char *_access_str[] = { \
>>> "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux" \
>>> }; \
>>> - union kvm_mmu_page_role role; \
>>> + union kvm_mmu_page_role _role; \
>>> \
>>> - role.word = __entry->role; \
>>> + _role.word = __entry->role; \
>>> \
>>> trace_seq_printf(p, "sp gen %lx gfn %llx %u%s q%u%s %s%s" \
>>> " %snxe root %u %s%c", __entry->mmu_valid_gen, \
>>> - __entry->gfn, role.level, \
>>> - role.cr4_pae ? " pae" : "", \
>>> - role.quadrant, \
>>> - role.direct ? " direct" : "", \
>>> - access_str[role.access], \
>>> - role.invalid ? " invalid" : "", \
>>> - role.nxe ? "" : "!", \
>>> + __entry->gfn, _role.level, \
>>> + _role.cr4_pae ? " pae" : "", \
>>> + _role.quadrant, \
>>> + _role.direct ? " direct" : "", \
>>> + _access_str[_role.access], \
>>> + _role.invalid ? " invalid" : "", \
>>> + _role.nxe ? "" : "!", \
>>> __entry->root_count, \
>>> __entry->unsync ? "unsync" : "sync", 0); \
>>> - ret; \
>>> + _ret; \
>>> })
>>>
>>> #define kvm_mmu_trace_pferr_flags \
>>>
>>
>> I think this unnecessarily uglifies the code, so I am not applying it.
>> Gleb, what do you think?
>
> Would you consider a version that only changes ret to _ret?
That would be more acceptable, or even better I guess you could stash
away p->len and return p->buffer + saved_len.
The thing is that it makes no sense for the caller's "ret" to alias any
of the other local variables of the macro. So the code gets uglier but
the only one to benefit is the compiler.
Paolo
next prev parent reply other threads:[~2014-07-26 7:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 13:27 [PATCH 1/4] x86/kvm: Resolve some missing-initializers warnings Jeff Kirsher
2014-07-25 13:27 ` [PATCH 2/4] kvm: Resolve missing-field-initializers warnings Jeff Kirsher
2014-07-25 14:06 ` Paolo Bonzini
2014-07-25 13:27 ` [PATCH 3/4] x86/kvm: Resolve shadow warnings in macro expansion Jeff Kirsher
2014-07-25 14:06 ` Paolo Bonzini
2014-07-25 17:18 ` Rustad, Mark D
2014-07-26 7:34 ` Paolo Bonzini [this message]
2014-07-30 21:19 ` [PATCH V2 " Mark D Rustad
2014-07-31 11:50 ` Paolo Bonzini
2014-07-31 16:59 ` [PATCH V3 " Mark D Rustad
2014-07-25 13:27 ` [PATCH 4/4] x86/kvm: Resolve shadow warning from min macro Jeff Kirsher
2014-07-25 14:06 ` Paolo Bonzini
2014-07-25 14:04 ` [PATCH 1/4] x86/kvm: Resolve some missing-initializers warnings Paolo Bonzini
2014-07-30 21:18 ` [PATCH V2 " Mark D Rustad
2014-07-31 11:50 ` Paolo Bonzini
2014-07-31 16:35 ` Rustad, Mark D
2014-07-31 16:50 ` Paolo Bonzini
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=53D35A12.9090404@redhat.com \
--to=pbonzini@redhat.com \
--cc=gleb@kernel.org \
--cc=jeffrey.t.kirsher@intel.com \
--cc=kvm@vger.kernel.org \
--cc=mark.d.rustad@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox