From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 31C767D34 for ; Wed, 11 Oct 2017 12:12:11 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75C764A702; Wed, 11 Oct 2017 10:12:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 75C764A702 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=maxime.coquelin@redhat.com Received: from [10.36.112.61] (ovpn-112-61.ams2.redhat.com [10.36.112.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3049A197F8; Wed, 11 Oct 2017 10:12:08 +0000 (UTC) To: Bruce Richardson , yliu@fridaylinux.org Cc: dev@dpdk.org References: <20171011095907.229893-1-bruce.richardson@intel.com> From: Maxime Coquelin Message-ID: <0a77b5a9-fa1a-6409-2518-5e2738888da9@redhat.com> Date: Wed, 11 Oct 2017 12:12:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171011095907.229893-1-bruce.richardson@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 11 Oct 2017 10:12:10 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH] vhost: fix false-positive warning from clang 5 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 10:12:11 -0000 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 Thanks, Maxime