From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id D330F2B9A for ; Wed, 11 Oct 2017 12:52:00 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 751CC20A23; Wed, 11 Oct 2017 06:52:00 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 11 Oct 2017 06:52:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=ggLuBPC+ONYiYQcZkPzEHgBpqv idGiR9g0vTzEggQuw=; b=s3Z0Iw6beEqO9IN3LnCMXyDyaVCixByd5ou4TNEbnA cmmnkiX0bjmXYqGO87GoGuxfyJmQUL9P0mSzj4YicTWgPgLGBTi7U2Xc6CvNeIcb ZtAFIZcB24sQJOP3Pw8qpiroVYHzUruyWQLu3NgKNNRDwQrE1TP6iFbkAZc17M/Y M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=ggLuBP C+ONYiYQcZkPzEHgBpqvidGiR9g0vTzEggQuw=; b=D7MUwEfyQgNrroxEhwmj0Y m1FWmLUW//1PMJ6MyrRsz0XjsIM8/EfglS5w8XDeaCo3GTr6xPWK7XSlyiWS01ZZ y3IKGcrpj4d1LlIUa0d58jmx019Xwre6W7W3gG83lVd5W81+GBynuLMGDeUD1xvw g9K4pQoSWj1bIO5F7FWFGsNENqJm1Huu2tMxfaDOsol5KcgcLFWOZSt6VI+K4zbL Vfc4gt0LVytik9yIWhMKHJyGyttQuLU+e3AtEpMlGu7f00AMPzB/vf/rTaFtyCn4 PojOB4Bus3Sa7muRkZ4JWBxKc2Z6fG/408AsV1UpKHNwXnE0E4tpi8X2cy7LJ8vg == X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 173D7247AD; Wed, 11 Oct 2017 06:52:00 -0400 (EDT) From: Thomas Monjalon To: Bruce Richardson Cc: dev@dpdk.org, Maxime Coquelin , yliu@fridaylinux.org Date: Wed, 11 Oct 2017 12:51:59 +0200 Message-ID: <8881744.fh4vGQZOj9@xps> In-Reply-To: <0a77b5a9-fa1a-6409-2518-5e2738888da9@redhat.com> References: <20171011095907.229893-1-bruce.richardson@intel.com> <0a77b5a9-fa1a-6409-2518-5e2738888da9@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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 10:52:01 -0000 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: > >=20 > > ../lib/librte_vhost/iotlb.c:318:6: warning: variable 'socket' is used u= ninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] > >=20 > > 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. > >=20 > > However, this is not immediately obvious, and is perhaps a little fragi= le, > > 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. > >=20 > > Fixes: d012d1f293f4 ("vhost: add IOTLB helper functions") > >=20 > > CC: Maxime Coquelin > > Signed-off-by: Bruce Richardson > > --- > > lib/librte_vhost/iotlb.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > >=20 >=20 > 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 =E2=80=98ret=E2=80=99 [-Werror=3Dunused-variable]