Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3608567rwo; Mon, 24 Jul 2023 13:48:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGS1BViaTGUf1QhZEiKh5iTVv8Ez+i5AdqjiLflZRwgSzHTHvTRgBChoQKCvAadsb+OEWzK X-Received: by 2002:a17:902:eccc:b0:1bb:809b:689b with SMTP id a12-20020a170902eccc00b001bb809b689bmr389626plh.34.1690231700198; Mon, 24 Jul 2023 13:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690231700; cv=none; d=google.com; s=arc-20160816; b=d43XaoOfSwnUZrHmdu4/60xbyOju6327bHKMHAhjz02/fItVqfiYEZlmP/SewoVP1S olMFhotcLAXDW/F63kSUWMDA8j4ZyjdIRBFieywHcVOalsDFGvSRg8n9PUBO95HC3Ior XuuoAIJo7zVm32pAzDcQ0n5DX2S6hUfY+z7l++oib/XrOCYF5eDXCueEQkgYAhlXT1J9 LvEaTgaxnqCUKruf/HgKVcMzzqnzfhkuABGmQV8SpuVFwbhF9rwvfDHrx+d6m9FaNARq hZF/4ZyOIBHKHvW6BnOeDHivUht3u39zggGluiYUbl/KjQ6bSShjy583DMfPxAoh+rIT b5mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=cGj2kfysUV4g0RCVNKokJtTz3uk6e/9iDcRIi02L+1I=; fh=mISdtvmNezrP8j4XhqS9GHAG47XVsy2kttUgIfu2gyI=; b=zpGW3qzoUzHpWLbLtvzoyTOFVSLiHEZf21+1FQXSUZxP04ZlGFW1aZ7OiWWQ1GjazO qGP5HgC8bPbrx6QgHMHU4jzqWlsx9z5Gbsf8gmCFL2hlQX4n0HWTzUT67Nsm2z3CDSLO 3wxx2RI1EJk4PQlkyBInaDoetCUfGOjgD9/b3oJurXPo/jioGZxUpTcy1eRe5yD0k2J9 d03zTs9vK8wvGYhTQAsBW9jmnV2QtJccFstq86PRUIgDa6tJ0bOPzz/7GGysSBRE//yQ 72WZCN+EaocXpo1a9DMXB30hUd0kg5rHkNS82x/sQrPCcJnmz6G+KuNjcakI6qVzLKb9 +QSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xfSlkQOs; 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 m5-20020a633f05000000b0055384eb4f43si8874647pga.221.2023.07.24.13.48.07; Mon, 24 Jul 2023 13:48:20 -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=xfSlkQOs; 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 S230435AbjGXUNB (ORCPT + 99 others); Mon, 24 Jul 2023 16:13:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbjGXUM5 (ORCPT ); Mon, 24 Jul 2023 16:12:57 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68AAC10C8 for ; Mon, 24 Jul 2023 13:12:56 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d10792c7582so1133372276.3 for ; Mon, 24 Jul 2023 13:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690229575; x=1690834375; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cGj2kfysUV4g0RCVNKokJtTz3uk6e/9iDcRIi02L+1I=; b=xfSlkQOsI3qPMDrf1nEk8lyQFBv+EIRpIaJyGMyR8weYJio1zxThHihc/jxp9zAOjd J+/G2FuQkT2HJYSV87vaVdZB0SpRldwcE8nbLypaCaNcXX4Zs4OgEs691Vcn/5/82wPv r6z6f1alHnhcHuFHHg0zl0pDNrW7IZSRrubQyKRQ1/bQ0uD1MrMZuQ2o30+jwbjPbEHv I3p2plZt2TCD480+dwdthrgFj/Be1npcPzMl42aNPfhOAgSXtnK0NcTgo4AWNRDrvcum zKr9t/I+eDdWeyqrRaNZeH7bSjELF0HRbRZZQofoJVnuJl8aN+eM8uAElrd8XwWwGGqm gPPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690229575; x=1690834375; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cGj2kfysUV4g0RCVNKokJtTz3uk6e/9iDcRIi02L+1I=; b=deAtqwwAovsmxmsnWIjNj02P/o9pucGnvItO8cA8y3Fdzgb8/u4bJzXBTn93d9gNKj h5ZujRNi1vUgWkqyFKPcwG6gsZ//FKh+ENCws6KVDwW/cbmZPlmcLgzwCIWVn+0TcWCb zs8mIoI2aqPnDE7exbF7LhvC8ajWtPiIj/rwtnd0JjXvpX6aD67Bj6ZHvZkI57Vfn/Ia Tf9dWlqK2qw0Jvy1vE2iJrJUSjEEGzBxeCXPVhd6JssU+5HV4KebLRBKZFsNnuyRwRmn OG/yMolkNG24cYvc7+Zt2gsgh36PkGlvGqbFzh7gcGeAwAKcpiTlxZGyp58F+u1OcM1N +kww== X-Gm-Message-State: ABy/qLanvcypkWW9i+gumBdtILRq5GicqOzy4ltvaoDjzZy+2W/beO+7 1exZA4CsgSv5tSxFS5x8oZyZei+e4zRa X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:5724:8dc0:46f0:f963]) (user=irogers job=sendgmr) by 2002:a25:bf91:0:b0:d11:b0d5:cd09 with SMTP id l17-20020a25bf91000000b00d11b0d5cd09mr20400ybk.8.1690229575692; Mon, 24 Jul 2023 13:12:55 -0700 (PDT) Date: Mon, 24 Jul 2023 13:12:44 -0700 In-Reply-To: <20230724201247.748146-1-irogers@google.com> Message-Id: <20230724201247.748146-2-irogers@google.com> Mime-Version: 1.0 References: <20230724201247.748146-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Subject: [PATCH v1 1/4] perf stat: Avoid uninitialized use of perf_stat_config From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Nathan Chancellor , Nick Desaulniers , 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 Cc: maskray@google.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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 perf_event__read_stat_config will assign values based on number of tags and tag values. Initialize the structs to zero before they are assigned so that no uninitialized values can be seen. This potential error was reported by GCC with LTO enabled. Signed-off-by: Ian Rogers --- tools/perf/tests/stat.c | 2 +- tools/perf/util/stat.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c index 500974040fe3..706780fb5695 100644 --- a/tools/perf/tests/stat.c +++ b/tools/perf/tests/stat.c @@ -27,7 +27,7 @@ static int process_stat_config_event(struct perf_tool *tool __maybe_unused, struct machine *machine __maybe_unused) { struct perf_record_stat_config *config = &event->stat_config; - struct perf_stat_config stat_config; + struct perf_stat_config stat_config = {}; #define HAS(term, val) \ has_term(config, PERF_STAT_CONFIG_TERM__##term, val) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 967e583392c7..ec3506042217 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -729,7 +729,7 @@ size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp) size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp) { - struct perf_stat_config sc; + struct perf_stat_config sc = {}; size_t ret; perf_event__read_stat_config(&sc, &event->stat_config); -- 2.41.0.487.g6d72f3e995-goog