xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32
Date: Fri, 23 Apr 2021 11:48:47 +0200	[thread overview]
Message-ID: <4282c7fb-4561-29c1-2bf8-18a50c5530ef@suse.com> (raw)
In-Reply-To: <20210423094343.5850-3-roger.pau@citrix.com>

On 23.04.2021 11:43, Roger Pau Monne wrote:
> Clang reports the following build error without CONFIG_PV:
> 
> hypercall.c:253:10: error: variable 'op' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>     if ( !is_pv_32bit_vcpu(curr) )
>          ^~~~~~~~~~~~~~~~~~~~~~~
> hypercall.c:282:21: note: uninitialized use occurs here
>     return unlikely(op == __HYPERVISOR_iret)
>                     ^~
> /root/src/xen/xen/include/xen/compiler.h:21:43: note: expanded from macro 'unlikely'
> #define unlikely(x)   __builtin_expect(!!(x),0)
>                                           ^
> hypercall.c:253:5: note: remove the 'if' if its condition is always true
>     if ( !is_pv_32bit_vcpu(curr) )
>     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> hypercall.c:251:21: note: initialize the variable 'op' to silence this warning
>     unsigned long op;
>                     ^
>                      = 0
> 
> Rearrange the code in arch_do_multicall_call so that the if guards the
> 32bit branch and when CONFIG_PV32 is not set there's no conditional at
> all.
> 
> Fixes: 527922008bc ('x86: slim down hypercall handling when !PV32')
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

I find it odd for the compiler to warn like this, but well ...
Acked-by: Jan Beulich <jbeulich@suse.com>

> Should the is_pv_32bit_vcpu be wrapped in an unlikely hint?

Not sure. Andrew did some similar rearrangement elsewhere for
other reasons, without adding unlikely(). Personally I think
we'd better add them, but then preferably add consistently as
possible.

Jan


      parent reply	other threads:[~2021-04-23  9:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23  9:43 [PATCH 0/2] x86/clang: build fixes Roger Pau Monne
2021-04-23  9:43 ` [PATCH 1/2] x86/oprofile: fix oprofile for clang build Roger Pau Monne
2021-04-23  9:45   ` Jan Beulich
2021-04-23  9:43 ` [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32 Roger Pau Monne
2021-04-23  9:46   ` Roger Pau Monné
2021-04-23  9:48   ` Jan Beulich [this message]

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=4282c7fb-4561-29c1-2bf8-18a50c5530ef@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    --subject='Re: [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32' \
    /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

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).