Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp810706rdg; Fri, 13 Oct 2023 01:33:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFarjIxRQHAnPPN4e7V3AwT8jiW+6lRtfp5ps5Lx1zF6+4YLjea+ty4g1RNUxHbJarhLlC3 X-Received: by 2002:a17:902:e84c:b0:1bc:4f04:17f4 with SMTP id t12-20020a170902e84c00b001bc4f0417f4mr35198186plg.30.1697186013337; Fri, 13 Oct 2023 01:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697186013; cv=none; d=google.com; s=arc-20160816; b=qNWOdJvmP7I/txoywpBcNFs7TqqgowlKUi1OON+5eY7WV465lTQ7EHomA+Yz6dpTQ+ BMkk3Wi0mMv9mwK5lJC8Fl2D5C0DjmzTGH3GkBm2oLc+xduaFuLuSjtMyBVP4Fo4IH/v KG2LDmrShRU4EKknZPOrMQzDogVXE3OyfgvWov3NBEt7KSsfMkLFgsiVQ6kfegoixQWN AAKazBHNw3h/rwhd9k2DS9+SsT0ktrpBtGP7cCluylgMafeyL6pLax27RcS3nEbYCeKd EESc7Jhnwlm3Stz+vD4Dw53NiaBrVM4uhMG7U6LkDShblyINBIrzjzdj8Ffy1bPNCL88 uElg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=cB14EJe8gaSIsrChU+ryklBeoO0BpFobtwILGows1XY=; fh=KYHB0Hbcs21QOfDPmkspM5dCjKtLFbFPWMvxkSNnYAg=; b=OlfLzV27idGOIyXEtRd2TdKv4wuPQuMVzIPMy/3INUDjXGI/dwmRMNZ5Y2rDyrx4Qo XD9jb3En7zk37LPHafipWbtaDJAbwHirK0rQCwgRaqisGDaa9AVfnDyxW1NzQX6Xoh/k 84e99e/c9tdx8donEj52BBBxe1HYe4gcPTGMQT7f3Bal0VnjHxDQdUk4ljmTbUm+GKmf rn9+d6bp1NlWu8LcBnoPbsFobgYTYTocy5G0ejPeRwSHB6y5UKeztObR0Hq/Mo9aO1RW OFIPid06yUvbFPNYFlgl7VDBsqyGQ+kwyUvy3m9yzt4qMacAhhCs0tl10RSRxmMcqvDW EefA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ny0ydS34; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k1-20020a170902c40100b001beef8ccd05si4485294plk.489.2023.10.13.01.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:33:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ny0ydS34; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 03F1981F38AD; Fri, 13 Oct 2023 01:33:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230048AbjJMIdW (ORCPT + 99 others); Fri, 13 Oct 2023 04:33:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbjJMIdS (ORCPT ); Fri, 13 Oct 2023 04:33:18 -0400 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B844A9; Fri, 13 Oct 2023 01:33:16 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id 6a1803df08f44-66d0f945893so15109906d6.1; Fri, 13 Oct 2023 01:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697185995; x=1697790795; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cB14EJe8gaSIsrChU+ryklBeoO0BpFobtwILGows1XY=; b=Ny0ydS34c3okbdjU+8YO+ebA+IEG6lo/0gGkOMQcfvMfwfBRzwk/Ca/4+WvpKRd64w 5X5fqh6AZaqJZHZvKfI6AUKXcpi+GYvRIRXQoFoOJdTGLnfj5ok2gmHdq9e/1jmCTMU6 uc2dv3YnZ8tekYf0cb2qQPBVAcoko3kYBJ/XIy3/d4pzqDHzcbeNDTHVeSn+SQiCppHu HFzVC2tIS/+QO15TLzHsucoQBo9nEYojdHYqjXnes2NTIyZaS44Y6cNi3HlR17lK4Ksg JippH/I6O/q15EzCyOo5N0zQaZN6nZqoCHJjFzJJcVO+Q2aCYK88Wp6V2Ivq14LbOjNW mcgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697185995; x=1697790795; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cB14EJe8gaSIsrChU+ryklBeoO0BpFobtwILGows1XY=; b=KoObdpMeJCnB9HiyKu/9URLt5CqIomYpEYIXEHPsQbTmy7neQNLwfLSwZFMhtMJ15A 0t+g+B57P3j3FmJxazbV/7sSSWE6WSbLiivL3DtqShehlcvMv6ICdtF2ETEHCVrCYlJQ L++6MyRsVg7/FbHfJZJCpLLICpccspbiiskjHoq1mlY76bLF69rnLvbF9Gw/eqm1tKqg ttgjniO7a4Ng4aOAouxji/nXje+g1b9AHTUJ6ZRst39JdCYcd1J4yACdAkcd8D3OD0Ok fz/Jkhvj8V2pMya7yNdZ17U59Z+J9q1uzPzp+8ea1zyz/2MLa1Vo0QQu7bqjEA9Pdi0X hkEw== X-Gm-Message-State: AOJu0YzXdE6ebkJ7sdSh4GYxD1lzpx5sTsuNJY8UyTctS9vc/stkx7Ah Mj3EXAQfJLAJAy+seuiuPL68wjSi5Rmwdoy0zkQjrLIg7gYOLfe2 X-Received: by 2002:a05:6214:5197:b0:66d:12d1:351c with SMTP id kl23-20020a056214519700b0066d12d1351cmr6602735qvb.31.1697185995112; Fri, 13 Oct 2023 01:33:15 -0700 (PDT) MIME-Version: 1.0 References: <20231013013536.2047-1-zhujun2@cmss.chinamobile.com> In-Reply-To: <20231013013536.2047-1-zhujun2@cmss.chinamobile.com> From: Yafang Shao Date: Fri, 13 Oct 2023 16:32:38 +0800 Message-ID: Subject: Re: [PATCH] selftests: bpf: remove unused variables To: zhujun2 Cc: shuah@kernel.org, ast@kernel.org, daniel@iogearbox.net, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, andrii@kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 13 Oct 2023 01:33:30 -0700 (PDT) On Fri, Oct 13, 2023 at 9:35=E2=80=AFAM zhujun2 wrote: > > These variables are never referenced in the code, just remove them. You can't remove them because they are really referenced in the CHECK() mar= co. Sending a patch without even testing a build is bad :( > > Signed-off-by: zhujun2 > --- > tools/testing/selftests/bpf/prog_tests/atomic_bounds.c | 1 - > tools/testing/selftests/bpf/prog_tests/kfree_skb.c | 2 -- > tools/testing/selftests/bpf/prog_tests/perf_branches.c | 6 +----- > .../testing/selftests/bpf/prog_tests/probe_read_user_str.c | 4 ++-- > tools/testing/selftests/bpf/prog_tests/test_overhead.c | 4 ++-- > tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c | 1 - > 6 files changed, 5 insertions(+), 13 deletions(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/atomic_bounds.c b/too= ls/testing/selftests/bpf/prog_tests/atomic_bounds.c > index 69bd7853e..4715cde38 100644 > --- a/tools/testing/selftests/bpf/prog_tests/atomic_bounds.c > +++ b/tools/testing/selftests/bpf/prog_tests/atomic_bounds.c > @@ -7,7 +7,6 @@ > void test_atomic_bounds(void) > { > struct atomic_bounds *skel; > - __u32 duration =3D 0; > > skel =3D atomic_bounds__open_and_load(); > if (CHECK(!skel, "skel_load", "couldn't load program\n")) > diff --git a/tools/testing/selftests/bpf/prog_tests/kfree_skb.c b/tools/t= esting/selftests/bpf/prog_tests/kfree_skb.c > index c07991544..b0992a9ed 100644 > --- a/tools/testing/selftests/bpf/prog_tests/kfree_skb.c > +++ b/tools/testing/selftests/bpf/prog_tests/kfree_skb.c > @@ -20,7 +20,6 @@ static void on_sample(void *ctx, int cpu, void *data, _= _u32 size) > { > struct meta *meta =3D (struct meta *)data; > struct ipv6_packet *pkt_v6 =3D data + sizeof(*meta); > - int duration =3D 0; > > if (CHECK(size !=3D 72 + sizeof(*meta), "check_size", "size %u != =3D %zu\n", > size, 72 + sizeof(*meta))) > @@ -65,7 +64,6 @@ void serial_test_kfree_skb(void) > struct perf_buffer *pb =3D NULL; > int err, prog_fd; > bool passed =3D false; > - __u32 duration =3D 0; > const int zero =3D 0; > bool test_ok[2]; > > diff --git a/tools/testing/selftests/bpf/prog_tests/perf_branches.c b/too= ls/testing/selftests/bpf/prog_tests/perf_branches.c > index bc24f8333..0942b9891 100644 > --- a/tools/testing/selftests/bpf/prog_tests/perf_branches.c > +++ b/tools/testing/selftests/bpf/prog_tests/perf_branches.c > @@ -13,7 +13,6 @@ static void check_good_sample(struct test_perf_branches= *skel) > int required_size =3D skel->bss->required_size_out; > int written_stack =3D skel->bss->written_stack_out; > int pbe_size =3D sizeof(struct perf_branch_entry); > - int duration =3D 0; > > if (CHECK(!skel->bss->valid, "output not valid", > "no valid sample from prog")) > @@ -43,7 +42,6 @@ static void check_bad_sample(struct test_perf_branches = *skel) > int written_global =3D skel->bss->written_global_out; > int required_size =3D skel->bss->required_size_out; > int written_stack =3D skel->bss->written_stack_out; > - int duration =3D 0; > > if (CHECK(!skel->bss->valid, "output not valid", > "no valid sample from prog")) > @@ -61,7 +59,7 @@ static void test_perf_branches_common(int perf_fd, > void (*cb)(struct test_perf_branche= s *)) > { > struct test_perf_branches *skel; > - int err, i, duration =3D 0; > + int err, i; > bool detached =3D false; > struct bpf_link *link; > volatile int j =3D 0; > @@ -102,7 +100,6 @@ static void test_perf_branches_common(int perf_fd, > static void test_perf_branches_hw(void) > { > struct perf_event_attr attr =3D {0}; > - int duration =3D 0; > int pfd; > > /* create perf event */ > @@ -143,7 +140,6 @@ static void test_perf_branches_hw(void) > static void test_perf_branches_no_hw(void) > { > struct perf_event_attr attr =3D {0}; > - int duration =3D 0; > int pfd; > > /* create perf event */ > diff --git a/tools/testing/selftests/bpf/prog_tests/probe_read_user_str.c= b/tools/testing/selftests/bpf/prog_tests/probe_read_user_str.c > index e41929813..a7c6ad8d6 100644 > --- a/tools/testing/selftests/bpf/prog_tests/probe_read_user_str.c > +++ b/tools/testing/selftests/bpf/prog_tests/probe_read_user_str.c > @@ -9,7 +9,7 @@ static const char str3[] =3D "mestringblubblubblubblubblu= b"; > static int test_one_str(struct test_probe_read_user_str *skel, const cha= r *str, > size_t len) > { > - int err, duration =3D 0; > + int err; > char buf[256]; > > /* Ensure bytes after string are ones */ > @@ -44,7 +44,7 @@ static int test_one_str(struct test_probe_read_user_str= *skel, const char *str, > void test_probe_read_user_str(void) > { > struct test_probe_read_user_str *skel; > - int err, duration =3D 0; > + int err; > > skel =3D test_probe_read_user_str__open_and_load(); > if (CHECK(!skel, "test_probe_read_user_str__open_and_load", > diff --git a/tools/testing/selftests/bpf/prog_tests/test_overhead.c b/too= ls/testing/selftests/bpf/prog_tests/test_overhead.c > index f27013e38..6161009df 100644 > --- a/tools/testing/selftests/bpf/prog_tests/test_overhead.c > +++ b/tools/testing/selftests/bpf/prog_tests/test_overhead.c > @@ -17,7 +17,7 @@ static __u64 time_get_ns(void) > > static int test_task_rename(const char *prog) > { > - int i, fd, duration =3D 0, err; > + int i, fd, err; > char buf[] =3D "test_overhead"; > __u64 start_time; > > @@ -66,7 +66,7 @@ void test_test_overhead(void) > struct bpf_program *fentry_prog, *fexit_prog; > struct bpf_object *obj; > struct bpf_link *link; > - int err, duration =3D 0; > + int err; > char comm[16] =3D {}; > > if (CHECK_FAIL(prctl(PR_GET_NAME, comm, 0L, 0L, 0L))) > diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c b/tool= s/testing/selftests/bpf/prog_tests/xdp_synproxy.c > index 8b50a992d..5af434353 100644 > --- a/tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c > +++ b/tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c > @@ -40,7 +40,6 @@ static bool expect_str(char *buf, size_t size, const ch= ar *str, const char *name > { > static char escbuf_expected[CMD_OUT_BUF_SIZE * 4]; > static char escbuf_actual[CMD_OUT_BUF_SIZE * 4]; > - static int duration =3D 0; > bool ok; > > ok =3D size =3D=3D strlen(str) && !memcmp(buf, str, size); > -- > 2.17.1 > > > > --=20 Regards Yafang