Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1034917pxb; Fri, 15 Apr 2022 19:05:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxLZLpP1FDrFG5UhDbEfyoKayQyc1IoYyXJ/1NrqZ5IwwQKSNy6z7ToegW5hd/Yr4w4HdP X-Received: by 2002:a17:902:9f8f:b0:158:c4ae:45ad with SMTP id g15-20020a1709029f8f00b00158c4ae45admr1757892plq.2.1650074754806; Fri, 15 Apr 2022 19:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650074754; cv=none; d=google.com; s=arc-20160816; b=FmQu6HscWuEduRRN+io0th+UU/pK281VivB7qKx1t2u5PZgnhGF5EtfICiDQXEtdiz GooBuLwCzb2rGqa99uL5E4V1/yYxRAIfhkfOsw9aQ+ucxOR7VUbaf/V904omfjwrt6/g vME5futWDPeZuAK1D8oCDgkvHvWlRNi3dtBYVfeExye1ucmhY/sVDpwDd7pT2TRFja+s zr3uj19B4EvQJz7bct5L0qwPar3/COBiQB34BVG6Fs6fGF4rEEFsMQXURW6D78ocpBda gDhZcUzMZhJorC03InJ/yaFsaDDdfJjBJidc2n6WC7ML+IIpC+/0hm+ux/YSLIavgear aLUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Fa2CFYKkelBEGVk6haGeks4blbwWFOTpyE9VaB2+kxk=; b=uWeVt7ja0jFG1kAYyWXS7ryWvHq4/anhej3vRf1quC/kr3tHN8W6IWFs0Ud/17Gs72 hAO0huonvKo6gNSB+zxsWxOQFbDBFBwRQe0xy/yuf3PtQsdnJhPu9MCZftWtvDC7k7kO xTt4KpADoDjJwGkfy2GxMHNmPq6X4BweuPiM+4t1pYycGJs4gMUr3pBIbnHUTQFvlHj7 Ct5OG1zAKZ//9yMKBYIY5WsUzv8uzyuPBF1uii8K8j8ESIzVvfKyvZpycdIHglhNNdE3 3ORlsDX7t6JW4WhgU9TiNOEuH+Jiluy6Bj9hKWKg8LYjNjyr9PYyjcsN3E4A0ALRj7Ky LNtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ies4O+s8; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 2-20020a17090a198200b001cba3fda35fsi3025081pji.85.2022.04.15.19.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:05:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ies4O+s8; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B342E114FCB; Fri, 15 Apr 2022 18:24:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345935AbiDOMSH (ORCPT + 99 others); Fri, 15 Apr 2022 08:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353274AbiDOMR5 (ORCPT ); Fri, 15 Apr 2022 08:17:57 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A83A04707F; Fri, 15 Apr 2022 05:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650024929; x=1681560929; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=2ffantDfDJF/384zKJkeiXccIRnCxuSDVGb4CQk+jZ0=; b=Ies4O+s8AqZLnHEIZ0IJNPM6xfmPukfRgM85f9LxToE56MeaIh1KBdpu TSGGT1njU1Ss+hw7bft5Ke9MaP382QymKYvuOSnSvm33IZvS3EU27uL5P uJQ3WTq6ZodIhee57kXjd8jE2B1VDkjjrb+cw1tm5VYV1bYpRMy6swneO TXh1YIBJOEucZX7OVG+Uo1owY9Swmzyb/AMlzMSP7sPrQD2emB6YotNpm lOlsRpdlNF1cnnZJby+xEKcrEId1+C/A98rsOQNm2g9rNbOhi+s053gau PoEsvUsv1uE+khi3heZdYls+I1WZr2K4Z0aX0IbQ5v8Hq8a4CmMRiOZo6 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262587876" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262587876" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 05:15:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="553130943" Received: from boxer.igk.intel.com (HELO boxer) ([10.102.20.173]) by orsmga007.jf.intel.com with ESMTP; 15 Apr 2022 05:15:21 -0700 Date: Fri, 15 Apr 2022 14:15:15 +0200 From: Maciej Fijalkowski To: Alexander Lobakin Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Magnus Karlsson , Jonathan Lemon , Nathan Chancellor , Nick Desaulniers , Dmitrii Dolgov <9erthalion6@gmail.com>, Quentin Monnet , Tiezhu Yang , Kumar Kartikeya Dwivedi , Chenbo Feng , Willem de Bruijn , Daniel Wagner , Thomas Graf , Ong Boon Leong , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH bpf-next 11/11] samples: bpf: xdpsock: fix -Wmaybe-uninitialized Message-ID: References: <20220414223704.341028-1-alobakin@pm.me> <20220414223704.341028-12-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220414223704.341028-12-alobakin@pm.me> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 14, 2022 at 10:47:20PM +0000, Alexander Lobakin wrote: > Fix two sort-of-false-positives in the xdpsock userspace part: > > samples/bpf/xdpsock_user.c: In function 'main': > samples/bpf/xdpsock_user.c:1531:47: warning: 'tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized] > 1531 | pktgen_hdr->tv_usec = htonl(tv_usec); > | ^~~~~~~~~~~~~~ > samples/bpf/xdpsock_user.c:1500:26: note: 'tv_usec' was declared here > 1500 | u32 idx, tv_sec, tv_usec; > | ^~~~~~~ > samples/bpf/xdpsock_user.c:1530:46: warning: 'tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized] > 1530 | pktgen_hdr->tv_sec = htonl(tv_sec); > | ^~~~~~~~~~~~~ > samples/bpf/xdpsock_user.c:1500:18: note: 'tv_sec' was declared here > 1500 | u32 idx, tv_sec, tv_usec; > | ^~~~~~ > > Both variables are always initialized when @opt_tstamp == true and > they're being used also only when @opt_tstamp == true. However, that > variable comes from the BSS and is being toggled from another > function. They can't be executed simultaneously to actually trigger > undefined behaviour, but purely technically it is a correct warning. > Just initialize them with zeroes. > > Fixes: eb68db45b747 ("samples/bpf: xdpsock: Add timestamp for Tx-only operation") > Signed-off-by: Alexander Lobakin Acked-by: Maciej Fijalkowski Magnus would tell you that you should fix this on libxdp side instead :) > --- > samples/bpf/xdpsock_user.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c > index 399b999fcec2..1dc7ad5dbef4 100644 > --- a/samples/bpf/xdpsock_user.c > +++ b/samples/bpf/xdpsock_user.c > @@ -1496,7 +1496,7 @@ static void rx_drop_all(void) > static int tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, > int batch_size, unsigned long tx_ns) > { > - u32 idx, tv_sec, tv_usec; > + u32 idx, tv_sec = 0, tv_usec = 0; > unsigned int i; > > while (xsk_ring_prod__reserve(&xsk->tx, batch_size, &idx) < > -- > 2.35.2 > >