Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2076784rdb; Mon, 9 Oct 2023 11:40:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIwstWgMqvUXCgOheexzG2FGW/Q8llh79vuf7lhWs0eHpEzNc9KbSN55lrZtPtLI9/XaIu X-Received: by 2002:a05:6a20:7343:b0:14c:3218:c1bd with SMTP id v3-20020a056a20734300b0014c3218c1bdmr18847565pzc.11.1696876828628; Mon, 09 Oct 2023 11:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876828; cv=none; d=google.com; s=arc-20160816; b=fFyx0uUFEA8ycZKOqBYYiGArsi3lA0WVXXK4E2v0yvCqSnFOQ0foOzeXJxI+6787tO CmnmvbhEgj10rG0kEKAIsuD0P0d/0VS6rYRWEYDyswDYnlUvJ3CcqPqJ2GE2FYzL5nCu cbIlq/cMc1L5UtliCKn43IPqwPb2mVPCN0q47B33aQkcIGg4OkHOR+cjyxL02KNJcrk7 2IlMCSvUN1CieK4It9UGktn9YZXL3yUs5y95B56Lgibl8I+WPWf6+4QvtrnoI/jHKalu w87M+rpapzXdZq0taa+6VmLzgzg8F/ZovrgQHfeH7UcsmI2qEUl4sp5Yqe/RnXMzjG0k A2sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=fapvG1sgoYBqHgoFOW9TcSIAiI5hx1hj0GAN7+v4jh4=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=p4faRp5CUoF0RGIoXwQtPU2P8zrmxtgt8gsmrxcPYJz9pt3X9GQSjI6ssY4yypxNC8 8NGvQqmiblN1WyGk8P+CRJJD1oqJXb7WOAAnGA9VTRAhKS+bAUR6ZJT7k1KXAlXvOgVF 2xkjVSl1UcTykazs7HsULaWyMABgD03WoXqZ5i6AmBXVGsyifM/5nisLYVW0ONWZCGL/ qWBtk1qoL8EEERV8SM84ZpTFzkcIQxvKNvier4z70029Fze2j/SqWAeJ1b7BdeFn38TI Lk2dnhr64wwjIiJkhvPt6Fv/s50jmN9jaLhU+Ybrb6Jm99mvNfi/wuZtpitfbs3pOduS y7CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OFk3wZEK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id z16-20020a656650000000b00578fcbfebdasi10253174pgv.734.2023.10.09.11.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:40:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OFk3wZEK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1C73D807FC07; Mon, 9 Oct 2023 11:40:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378285AbjJISj6 (ORCPT + 99 others); Mon, 9 Oct 2023 14:39:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378229AbjJISjs (ORCPT ); Mon, 9 Oct 2023 14:39:48 -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 7BAD7113 for ; Mon, 9 Oct 2023 11:39:43 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5a507eb61a6so73204577b3.1 for ; Mon, 09 Oct 2023 11:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876782; x=1697481582; 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=fapvG1sgoYBqHgoFOW9TcSIAiI5hx1hj0GAN7+v4jh4=; b=OFk3wZEKRbsVyMjM+9CyBIeNKC7CQOS4Q3CWIkEQeGHzOExrefIAwk74TnX0ULOJ7g gf2IuNSvlsl6dvg/i0SupHeYkkjvTdsN7bOvIrT3Z8mPfIqG5UwbhXnLDT9Qzb+ofA9o HyUTVuUVnDK32cxvmyg8rgr7yhi41QWGmryGHjD/04A3i5Ndq4WdtcKveOiTnf2Z/Ids fxdQrTkfCCthLonmrUPnKPeMCQ7gBZQeY8Orn3AIDZnPR/NZdyg+syaOlLsXOnLfPYyq 8iz4w7NCFe1pxo4AUhRpECmwBxRKhlL6r7B7HFXOLzS0b+sH04tgW4CxBktzn0hfnTYM FyeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876782; x=1697481582; 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=fapvG1sgoYBqHgoFOW9TcSIAiI5hx1hj0GAN7+v4jh4=; b=TfPAT+t2iRNfczKuKQoMhOK0cLp5W//Ls9dgrB/8jB2BNZ8xGaBnp0Yt+ZXf39qpkG tbAyH7O4dN95IbEraED25auW9yIFyyHwvea6UJy0rjnRdCrgJX81a/JDhiinF18Ll3a8 qxYNYTtQAxWFU237kyo43+zWR3epv+9Z4NAZ+GTzsl0sIv0ShOlykq4X1omvXB6qRimV Qg2x3pZfv7x3kPaSzWuaeuhXJGVeMcaSnIenLSbS21QuIMxtOyN22d8GFfelaksh/d+A nD7iDfMqhox5OIJNwRzvSTc4zS7Lt98655eVN705szTVt9mrEy/26iNhuNOrePD45MIZ jgCg== X-Gm-Message-State: AOJu0YxfvXR2YUemwTdX9tXSYEw6CiQK2ynVcGeFWD1SkGw2gOsKl1hs F3zmkwdofyxtkg7IsgwZEqEq6aDX+/PB X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a81:bc03:0:b0:59b:c6bb:babb with SMTP id a3-20020a81bc03000000b0059bc6bbbabbmr297631ywi.6.1696876782479; Mon, 09 Oct 2023 11:39:42 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:08 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-8-irogers@google.com> Mime-Version: 1.0 References: <20231009183920.200859-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v3 06/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 , Yang Jihong , Huacai Chen , Ming Wang , Kan Liang , Ravi Bangoria , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:40:11 -0700 (PDT) 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 = 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; - if (!env || !env->cpuid) { /* Assume local operation */ + if (!env->cpuid) { /* Assume local operation */ status = 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; - if (!env || !env->nr_pmu_mappings) { /* Assume local operation */ + if (!env->nr_pmu_mappings) { /* Assume local operation */ status = 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; - if (!env || !env->pmu_mappings) { /* Assume local operation */ + if (!env->pmu_mappings) { /* Assume local operation */ status = perf_env__read_pmu_mappings(env); if (status) return NULL; -- 2.42.0.609.gbb76f46606-goog