From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id B9A071B1B1 for ; Wed, 11 Oct 2017 13:01:41 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 04:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,361,1503385200"; d="scan'208";a="1229555945" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.37]) by fmsmga002.fm.intel.com with SMTP; 11 Oct 2017 04:01:38 -0700 Received: by (sSMTP sendmail emulation); Wed, 11 Oct 2017 12:01:37 +0100 Date: Wed, 11 Oct 2017 12:01:37 +0100 From: Bruce Richardson To: Thomas Monjalon Cc: dev@dpdk.org, Maxime Coquelin , yliu@fridaylinux.org Message-ID: <20171011110137.GA40132@bricha3-MOBL3.ger.corp.intel.com> References: <20171011095907.229893-1-bruce.richardson@intel.com> <0a77b5a9-fa1a-6409-2518-5e2738888da9@redhat.com> <8881744.fh4vGQZOj9@xps> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8881744.fh4vGQZOj9@xps> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.8.3 (2017-05-23) Subject: Re: [dpdk-dev] [PATCH] vhost: fix false-positive warning from clang5 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 11:01:42 -0000 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 > > > Signed-off-by: Bruce Richardson > > > --- > > > 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 > > 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