From: Bruce Richardson <bruce.richardson@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>,
yliu@fridaylinux.org
Subject: Re: [dpdk-dev] [PATCH] vhost: fix false-positive warning from clang5
Date: Wed, 11 Oct 2017 12:01:37 +0100 [thread overview]
Message-ID: <20171011110137.GA40132@bricha3-MOBL3.ger.corp.intel.com> (raw)
In-Reply-To: <8881744.fh4vGQZOj9@xps>
On Wed, Oct 11, 2017 at 12:51:59PM +0200, Thomas Monjalon wrote:
> 11/10/2017 12:12, Maxime Coquelin:
> > On 10/11/2017 11:59 AM, Bruce Richardson wrote:
> > > When compiling with clang extra warning flags, such as used by default with
> > > meson, a warning is given in iotlb.c:
> > >
> > > ../lib/librte_vhost/iotlb.c:318:6: warning: variable 'socket' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> > >
> > > This is a false positive, as the socket value will be initialized by the
> > > call to get_mempolicy in the case where the NUMA build-time flag is set,
> > > and in cases where it is not set, "if (ret)" will always be true as ret is
> > > initialized to -1 and never changed.
> > >
> > > However, this is not immediately obvious, and is perhaps a little fragile,
> > > as it will break if other code using ret is subsequently added above the
> > > call to get_mempolicy by someone unaware of this subtle dependency.
> > > Therefore, we can fix the warning and making the code more robust by
> > > explicitly initializing socket to zero, and moving the extra condition
> > > check on ret into the #ifdef alongside the call to get_mempolicy which sets
> > > ret.
> > >
> > > Fixes: d012d1f293f4 ("vhost: add IOTLB helper functions")
> > >
> > > CC: Maxime Coquelin <maxime.coquelin@redhat.com>
> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > > ---
> > > lib/librte_vhost/iotlb.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> >
> > I agree this is a bit fragile. Thanks for handling this:
> > Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>
> New error with this patch:
>
> lib/librte_vhost/iotlb.c:303:6: error:
> unused variable ‘ret’ [-Werror=unused-variable]
>
See it now, when the VHOST NUMA option - which is different from the EAL
one, I notice - is disabled. I'll do a v2 and remove the variable
completely as it doesn't seem necessary.
/Bruce
next prev parent reply other threads:[~2017-10-11 11:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 9:59 [dpdk-dev] [PATCH] vhost: fix false-positive warning from clang 5 Bruce Richardson
2017-10-11 10:12 ` Maxime Coquelin
2017-10-11 10:51 ` [dpdk-dev] [PATCH] vhost: fix false-positive warning from clang5 Thomas Monjalon
2017-10-11 11:01 ` Bruce Richardson [this message]
2017-10-11 11:28 ` [dpdk-dev] [PATCH v2] vhost: fix false-positive warning from clang 5 Bruce Richardson
2017-10-11 12:49 ` Thomas Monjalon
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=20171011110137.GA40132@bricha3-MOBL3.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=thomas@monjalon.net \
--cc=yliu@fridaylinux.org \
/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;
as well as URLs for NNTP newsgroup(s).