Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp23069lfe; Fri, 15 Apr 2022 17:38:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx78quOJ4isTTQuvOhlQkK4b1DThamJE/KnnkVw/kKiaf4Ni0Zf5RSQ3B/zRDZ92FEIBacu X-Received: by 2002:a17:903:31cd:b0:158:542b:908d with SMTP id v13-20020a17090331cd00b00158542b908dmr1434384ple.16.1650069492647; Fri, 15 Apr 2022 17:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650069492; cv=none; d=google.com; s=arc-20160816; b=Wz+bKGVlzcKF3un1/tOPXNobrs+L8PBt4f9xw6RohxUhxI6ujoj2m9UeXl/C3AeBbl yWUE2/bAZzUy5LzyvyayDLPUk/p9mAzlDk83wq7dDjKiUydKf/lf/V30h2yZvmx+b7vb 4GKG76OUMbDwcHqkZPultWdJazOc8ghZcnjYxVF9stNser2afe2ZhlNTw3eoUFs34iFH m/5usySONyzgzN5L/CjqPGpiyxlCzXMpsto0ST5lthxgOb648ZSnhbflgn5pZzzlikdo I2uhqUhuSwXJR6CHSykkmbGvg2cAiOFSvVhamykm6MRuj/9V4bqPNhzYSvoEYuwP/Eaj 3Kig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Yt2VN7++aYPK9eu5pWHquEiEtNaJwbDE38qtF9BMyQg=; b=rcGbijNJuKSvYrClHSXo47/Y62oXcE65edGmuVr6za5DtCrlGQnpbS+3yl6Lb/5nU8 8XWbnuMG6GRjjgCVbPJMFsyhm+EKysbIiPF/OLYMkGi+bBhZuJ2rpad5XS9qpPBTQEnL ztT0w0nX5N3hCA09w/4AwNcze95HtSGV8uwDxPXlrrzm6anNlWLeBItFhlFn9N2feiaN tbaQcyAa19uB5S6KWLRk3+G75h8OYqYM5T2l+11C7z2+oaqnCLw+5NTIbaGxOCU7+/t+ Qmrz/tw9iO0eFG77VOQrZbIpWmzEOjt3kRZVKjlB2KQ8VtBb+wzDc6rp0G+q/7sWg+6d ef4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jt1cEPvP; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u190-20020a6385c7000000b0039919e9128dsi2643508pgd.782.2022.04.15.17.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:38:12 -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=@kernel.org header.s=k20201202 header.b=Jt1cEPvP; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E00E91EADC; Fri, 15 Apr 2022 17:33:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356674AbiDPAAn (ORCPT + 99 others); Fri, 15 Apr 2022 20:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356668AbiDPAAi (ORCPT ); Fri, 15 Apr 2022 20:00:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C83C498F51; Fri, 15 Apr 2022 16:58:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7743FB831BC; Fri, 15 Apr 2022 23:58:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BBDDC385AF; Fri, 15 Apr 2022 23:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650067086; bh=5uISNHkYs1nGeyc2gtdd+Tm04KE96qpSVHvbrefArMc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Jt1cEPvPZxAt277UsraKj/YntuLhptaIO0NeOoBBAJDmYF1z/mStui6jXWV0GMnqX dyqYf1TMHxb7PWpzyRt3oSlha9fe5zBVnyqmlGednBX8P8ko8N0HTexKDk6c3tSBB3 6zqYAjjxPryXxFbyZorSqbmnRaq0y/GhyOhgo+j28OJ56+USX+9R9asuXC3wIvmnp6 kQQAaz0T2BsILtv3OkI/ql1VWrXFjGpJ6m9eu//RlLL/uJv8NQj6HCHVSVeuxz4yky HTw0KcX6ibn7YJNAHwznAY8jC5kD2sPOO6N2ZOGx3cQooF71AT8R9zJnTj1DSKOrIU mHkpoX9jMejVg== Received: by mail-yb1-f173.google.com with SMTP id g34so16776700ybj.1; Fri, 15 Apr 2022 16:58:06 -0700 (PDT) X-Gm-Message-State: AOAM532Cg/Vb84C7a3lB+QOQ+68eRDpWdx+kRuKVIREfrIidwRT2FUQT dsHtTUmnmzjDnWzIXTsyn8gC9HQd7RHWJ1g9KuU= X-Received: by 2002:a25:8546:0:b0:61e:1d34:ec71 with SMTP id f6-20020a258546000000b0061e1d34ec71mr1262667ybn.259.1650067085117; Fri, 15 Apr 2022 16:58:05 -0700 (PDT) MIME-Version: 1.0 References: <20220414223704.341028-1-alobakin@pm.me> <20220414223704.341028-12-alobakin@pm.me> In-Reply-To: <20220414223704.341028-12-alobakin@pm.me> From: Song Liu Date: Fri, 15 Apr 2022 16:57:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next 11/11] samples: bpf: xdpsock: fix -Wmaybe-uninitialized 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 , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , 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, open list , Networking , bpf , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 3:47 PM 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: Song Liu > --- > 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 > >