Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3653513rwo; Mon, 24 Jul 2023 14:37:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlHvOE75LhSomXDbxNFlz1RSpLjbzXYo/wkYmsqZf3QhoKtcJEIv/tS3GWTiE+UosIKM2lAm X-Received: by 2002:a17:906:3185:b0:965:fb87:4215 with SMTP id 5-20020a170906318500b00965fb874215mr10321287ejy.15.1690234673393; Mon, 24 Jul 2023 14:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690234673; cv=none; d=google.com; s=arc-20160816; b=fVhq2hXRGbbB/TBfsLu+tzcE1hW9gF31X+/JW0W2oFD2h45FWqGC5wVUhcbKTEAmS4 8sf+b5NKPp94NpGR4L77F4gUQ81gm27Se6hWXe25it1FAQypzuutyNNVbB7XfZ/0C/UY f+Ppwp4HMzRwEetMRPMOvMvoul+ELcAIq5cxxSIRldU35OeCLjEZag+GMusNucghMDyv ggTDc6vfz4ppYpVr0MeE63gyoaMGnEaT/IiI6kVcXwT+slbDYTKYKBUg7v+VsbGPkR7P lQyAqeOaulBYE0H30AXsCe/SBfP9JPmdUnQYTuVk7F840193MImluVVli1E9RCIiWrgV X+fA== 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=DwEv6m7WdEj0WSS/WT/tsZ81hOCgU00T3UAZ9HdZAtM=; fh=DaEtDrgDr1LPTSaNuq0RJp7cCpUYMoVYFCVtmGKA8Ew=; b=ORbBUVQBd7DX3RcSrR3clJeXRscArWP0ER2N4MYGF14EcVtadXSZqLJthbSIGvhAzE ECw1qXPvIcWfZYHrrfjGHpWH7NF4WYaR4KzodaE4re7lKKOaaozJ0apfINfz49e3aIeL Mr7FL3hxc8s2bWv6nNYsJP5YH04LvjKEZsHRO5T9SlnCKDHhki8g0MzZi/dyzF48yEXe uzZZDBymYDPjTaicdY5RS1eBFw4TcQsIbk3VRTaTfeUOT3SS8I2UntQcex2LqnC1vjz/ wIZp6/aemUY689IxX0q9Qpd0Q+S9Wt6AmJaSnBAk816tSdPmpXjOhnzfaYoNwOIns3mc 1czg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ZXJZqU++; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a1709066a8f00b0098f34870d82si7819939ejr.159.2023.07.24.14.37.28; Mon, 24 Jul 2023 14:37:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ZXJZqU++; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229662AbjGXVCC (ORCPT + 99 others); Mon, 24 Jul 2023 17:02:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjGXVCA (ORCPT ); Mon, 24 Jul 2023 17:02:00 -0400 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F911E70 for ; Mon, 24 Jul 2023 14:01:59 -0700 (PDT) Received: by mail-vs1-xe33.google.com with SMTP id ada2fe7eead31-440ad406bc8so1225591137.3 for ; Mon, 24 Jul 2023 14:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690232518; x=1690837318; 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=DwEv6m7WdEj0WSS/WT/tsZ81hOCgU00T3UAZ9HdZAtM=; b=ZXJZqU++vguNApIwgPzo62X8jAfLDKCBIFCtO0mpcS9spwAkiHrJzjk3NqFkmjzfUJ 00W5rK4Im2ZLUNSjWMonuSYFVPgD8zpl6ZQdlEvys7eXO3FIpf57vu1SQFRoHiQ1qC8/ PnZlXRVgzntWJdt92inSsTgCxwbzn3SijHCpCqHJHrkAISuXS7tWqmyfiUDdgZ9fH17a Xu+A8LW0LEpsgVEfA3+ZXDrcitcAT9LYOM0ADJfrw4tSxp7RaNbqFUwsfrQ7XFNnnuBs z1dzEXCIAVkaEXj7JfwKwv521RnbBdchV5jPs7lA15JjkKx3v3d5BG0lhYYIhc1GlFAX 77JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690232518; x=1690837318; 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=DwEv6m7WdEj0WSS/WT/tsZ81hOCgU00T3UAZ9HdZAtM=; b=TxvOpdxYRl2mx6gDbjCsww9J5cvq4Nair79I+r1tT5DlaEKwEGoD7VHdqoHMGdeHHA 4p+KcuaWuqMpNtUGpiM2HhHzs0q8hOtzi52wyhYHFLyRiadZPss3HR9NS5Q8uiMJTPqx Q8OBINexmyee5u96h52KCjMjveE4QSfLnndluYaxpTYgwVgSWPXPJ0LbfTZp7ySmaLm1 t6FMt1H72+RBSUKQd+SRJECndRkwXjRumvZidi63oNDYt9xWy6r+sJpv7/Yi9fQRQ9FG RMxhyii8w9plSryXR/G7BqhYSlRUpJXwzTv66AssD7AvitFGwsq8DVbJ/IAik9H0HS0C F/HA== X-Gm-Message-State: ABy/qLZ/WKqoToskZd/2HgUHyVQ5KHRrcW9fpqDFnTSODBnCXv91kkEg Rk/0zOYEm/OrG2GJI6hbpacTkaXejylkEWtau2tl9w== X-Received: by 2002:a67:ef84:0:b0:443:6392:71ea with SMTP id r4-20020a67ef84000000b00443639271eamr2866297vsp.34.1690232518329; Mon, 24 Jul 2023 14:01:58 -0700 (PDT) MIME-Version: 1.0 References: <20230724201247.748146-1-irogers@google.com> <20230724201247.748146-3-irogers@google.com> In-Reply-To: <20230724201247.748146-3-irogers@google.com> From: Nick Desaulniers Date: Mon, 24 Jul 2023 14:01:46 -0700 Message-ID: Subject: Re: [PATCH v1 2/4] perf parse-events: Avoid use uninitialized warning To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Nathan Chancellor , Tom Rix , Kan Liang , Yang Jihong , Ravi Bangoria , Carsten Haitzler , Zhengjun Xing , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev, maskray@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Mon, Jul 24, 2023 at 1:13=E2=80=AFPM Ian Rogers wro= te: > > With GCC LTO a potential use uninitialized is spotted: > ``` > In function =E2=80=98parse_events_config_bpf=E2=80=99, > inlined from =E2=80=98parse_events_load_bpf=E2=80=99 at util/parse-ev= ents.c:874:8: > util/parse-events.c:792:37: error: =E2=80=98error_pos=E2=80=99 may be use= d uninitialized [-Werror=3Dmaybe-uninitialized] > 792 | idx =3D term->err_term + error_po= s; > | ^ > util/parse-events.c: In function =E2=80=98parse_events_load_bpf=E2=80=99: > util/parse-events.c:765:13: note: =E2=80=98error_pos=E2=80=99 was declare= d here > 765 | int error_pos; > | ^ > ``` > So initialize at declaration. This common pattern in C is error prone (conditional assignment in the callee; callers maybe forget to initialize, then unconditionally use the value). Clang's static analyzer can spot these, but isn't run for tools/ AFAIK. Reviewed-by: Nick Desaulniers > > Signed-off-by: Ian Rogers > --- > tools/perf/util/parse-events.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-event= s.c > index acde097e327c..da29061ecf49 100644 > --- a/tools/perf/util/parse-events.c > +++ b/tools/perf/util/parse-events.c > @@ -762,7 +762,7 @@ parse_events_config_bpf(struct parse_events_state *pa= rse_state, > struct list_head *head_config) > { > struct parse_events_term *term; > - int error_pos; > + int error_pos =3D 0; > > if (!head_config || list_empty(head_config)) > return 0; > -- > 2.41.0.487.g6d72f3e995-goog > --=20 Thanks, ~Nick Desaulniers