From nobody Fri Feb 13 15:39:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82599CE7A88 for ; Sat, 23 Sep 2023 05:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbjIWFg2 (ORCPT ); Sat, 23 Sep 2023 01:36:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjIWFgD (ORCPT ); Sat, 23 Sep 2023 01:36:03 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43649CE3 for ; Fri, 22 Sep 2023 22:35:53 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59f4bd6905aso17796117b3.3 for ; Fri, 22 Sep 2023 22:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695447352; x=1696052152; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=9JLMR1XL8zAjwZWVAlK6A4BDEZJsECGT2sz2xABlKYc=; b=NSUJS5aNzLfDWHxLQARpRVVvDRT53eBlVVXHiRc2Nudz44dSTtwVLIF+b51LEQmtOz sRBdMAINcll4En1D9+a/nBy+LsWOYSib2lhmtHiQq/pnbq/NyOD8p04+aMPATmoC01uB wDFIeCViyq7tWj04Cs2mXJAKvQ/F4tISFZQxr3FrFp+KXaOS8y+u1JGTUmbVKDYYloWn UgfsfSKSYBbm/Hv2EnAgnW4T++9PLD1VusNNEqHZdYLJvzk/87BQ+n8TFCsIEzxlQDSa 4qZxi4xqMokew1sEBxCo/CTf4I7a2DRv4AqhqWVVqE5X5fQenCALvcj3AwzbEywCQyoO kHBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695447352; x=1696052152; h=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=9JLMR1XL8zAjwZWVAlK6A4BDEZJsECGT2sz2xABlKYc=; b=M8aeVUrQs4P9nl0waoRlbYX7D9WGLsqJLGiHrHNm5F1UEmbP0RSX3cb+SFnmV6lBmq bFAOiotag08Sa5zUdxhjJO0lhy1aLTj35KYAMYk1tIyphFr/p3+uxCXVGL3u4/wAZBth 2SFP78aBZvaeZiy6l3WkzSl2mTsKKyCjgZ7h47M8DpMzu+Kbn4yxvHccLFa0Mn+Qt9it R9nDLyyG70VWhEX3aMu9lv2XoM6aXsIOfdSqlzVhPV+murH1mWhoRiZ4aERM0LuLBRgB CAoOyQkBcIfgJnVR7FHsJqqoDViQNwYoPDxs7JFuYLY9/Jh86B/Zj/msasgiT6oNqG1X lM7Q== X-Gm-Message-State: AOJu0Yyv2DXrUwblqeaKfY0uOPApCJrXFcFoQFlkxpspaXgETyRJj5Mi U4Aajrbe3eLsf178rpKYG8J6qtAnNn4L X-Google-Smtp-Source: AGHT+IGwoVliXHNo2Ezm8GW+6WCcr1eN33xbWzqXWDeiL+JMjQWZaBaqiW/AxKNeH9OmHAU2FWAtbGPCLBod X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:a376:2908:1c75:ff78]) (user=irogers job=sendgmr) by 2002:a05:6902:1105:b0:d81:6637:b5b2 with SMTP id o5-20020a056902110500b00d816637b5b2mr14384ybu.0.1695447352596; Fri, 22 Sep 2023 22:35:52 -0700 (PDT) Date: Fri, 22 Sep 2023 22:35:04 -0700 In-Reply-To: <20230923053515.535607-1-irogers@google.com> Message-Id: <20230923053515.535607-8-irogers@google.com> Mime-Version: 1.0 References: <20230923053515.535607-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Subject: [PATCH v1 07/18] perf env: Remove unnecessary NULL tests From: Ian Rogers To: Nathan Chancellor , Nick Desaulniers , Tom Rix , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Yicong Yang , Jonathan Cameron , Yang Jihong , Kan Liang , Ming Wang , Huacai Chen , Sean Christopherson , K Prateek Nayak , Yanteng Si , Yuan Can , Ravi Bangoria , James Clark , Paolo Bonzini , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" clang-tidy was warning: ``` util/env.c:334:23: warning: Access to field 'nr_pmu_mappings' results in a = dereference of a null pointer (loaded from variable 'env') [clang-analyzer-= core.NullDereference] env->nr_pmu_mappings =3D pmu_num; ``` As functions are called potentially when !env was true. This condition could never be true as it would produce a segv, so remove the unnecessary NULL tests and silence clang-tidy. Signed-off-by: Ian Rogers --- tools/perf/util/env.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index a164164001fb..44140b7f596a 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -457,7 +457,7 @@ const char *perf_env__cpuid(struct perf_env *env) { int status; =20 - if (!env || !env->cpuid) { /* Assume local operation */ + if (!env->cpuid) { /* Assume local operation */ status =3D perf_env__read_cpuid(env); if (status) return NULL; @@ -470,7 +470,7 @@ int perf_env__nr_pmu_mappings(struct perf_env *env) { int status; =20 - if (!env || !env->nr_pmu_mappings) { /* Assume local operation */ + if (!env->nr_pmu_mappings) { /* Assume local operation */ status =3D perf_env__read_pmu_mappings(env); if (status) return 0; @@ -483,7 +483,7 @@ const char *perf_env__pmu_mappings(struct perf_env *env) { int status; =20 - if (!env || !env->pmu_mappings) { /* Assume local operation */ + if (!env->pmu_mappings) { /* Assume local operation */ status =3D perf_env__read_pmu_mappings(env); if (status) return NULL; --=20 2.42.0.515.g380fc7ccd1-goog