Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1364362pxj; Fri, 4 Jun 2021 12:27:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4dlmNnNMi7l4uaLAzTPr/y2BpAkcJ3AS3dbdb15RYJ+YssFXM25Q6bbVV+4n9BL7TdgTF X-Received: by 2002:a50:f10b:: with SMTP id w11mr6598019edl.308.1622834839207; Fri, 04 Jun 2021 12:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622834839; cv=none; d=google.com; s=arc-20160816; b=jVHadfpVEA3O42GMre1tQmxpCyDs56ZEqtgnOX9VcgfYhmGO9F04VUF4CvRjD6AKUY yGhuR/++8N9S5AFrgBLMJa6Ygqd+Oime9GgxF8GYMio3s2RogWK2OiQrPnXCHVbWFIOF jLmuyGnTAYxUpASp2IJLuPrfnvmIwwAsW9h2qHhS0naZoMFYvq9GcEGQMxSHX9FMd8cb PTYYiAb8xl6cS04WkIdu3m2dqGuxBDL/1KHm4M01VStM8sjuVL4xNgEg/jWwNHawAvYj Ba/BqvoFV/UNrV11Lhv7Jb2ubBo+5DXqXXVFksa92fKMPHlrDiL531023DDDgXZJBINM f/yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=P3arXY3Iq0Fx3qKjwqpP6enbStCHFC2viArbJLk+gG4=; b=w5aoyIfWS1Fmn+2ESlX+YGDo3dz+oVQVQ5zErn8XV5PPn9vtdbqOtJEGeMluy30Z5F eqDiK2iit7d9XGl14foIUM0yiuOKIhtcvgPl2IdelMqYxYtomAt2/aUhugb7q0nTA7HL L4NaEn7gg0lVXIpn33F21ob2LxHE/y2336LFbfeZ0zXMzMX2QcBa5CkegiKOOrL5yGIB u+Pqxwl9om8UeB0eWWj6uO+dKV8MhA3NbBxaePbiNHyJ2CfifY9EjtbhGWlGbIe3eiw5 scZ8P1F0rx1bKotVAS6rSEGJjVMnglAjbjOovomWcuBZ87RsgvZkQS7BLl746GdTnptj msGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KL8HzrlA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp35si3562621ejc.731.2021.06.04.12.26.54; Fri, 04 Jun 2021 12:27:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KL8HzrlA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbhFDT1e (ORCPT + 99 others); Fri, 4 Jun 2021 15:27:34 -0400 Received: from mail-io1-f46.google.com ([209.85.166.46]:41575 "EHLO mail-io1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhFDT1d (ORCPT ); Fri, 4 Jun 2021 15:27:33 -0400 Received: by mail-io1-f46.google.com with SMTP id p66so9394731iod.8 for ; Fri, 04 Jun 2021 12:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=P3arXY3Iq0Fx3qKjwqpP6enbStCHFC2viArbJLk+gG4=; b=KL8HzrlALh6cM6GjOSSchK4iJtooFOlCyIW+t+cN/hfUCT3crtKc5d+nn+U4oJ85C7 6cPt8MdIJgVcdCbheM2RstyYaQRazt0+1HBK5krcnQ3JXz1qjZlKvc3InCwq8ewndo7H Ju0fm9u9B97rgmc3e3b6XO5DT0kLdyIXwFGpk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=P3arXY3Iq0Fx3qKjwqpP6enbStCHFC2viArbJLk+gG4=; b=rLigFONu5Zhpkf1prddNXxCdV0aTYV9/hiYlbOWjszq+j8+E4g1c6t5Re0IzRifhRt 5A4Dx8BIiLTQAlgBCvZf2lpH/btMQ9zFzfGdkSDUDlhogJbFJQ+FW3cBDPaqGjZ5BYee awp/qa4eM2cUNBJKxcOU+vW5mR1FyTD6t6UGz1ZsuAId0WmOE3ABoJo/GKwkQq0oTe/5 /fCWPwZkHgWbtRXobVVnA4EhDENEc7csPBAZ55p6l04cnJ8x9YYJbMzrlbQrfDzfNWcg hvCwCI051x/6zaTIGM51pW/2goOvBYGhet1xeNkGzIhPzgiFCh39MLsvw1T3cUeWBI88 TCSg== X-Gm-Message-State: AOAM532tlfOkN6lWm2IigGoNPwOzhrlfJuitexdDRuhjpM/61MXdqsp1 WB23iI5LpHS7sIIraj5GdWCpjECKxs1WoA== X-Received: by 2002:a05:6602:2215:: with SMTP id n21mr5042939ion.80.1622834675098; Fri, 04 Jun 2021 12:24:35 -0700 (PDT) Received: from mail-il1-f172.google.com (mail-il1-f172.google.com. [209.85.166.172]) by smtp.gmail.com with ESMTPSA id a22sm2876393iot.37.2021.06.04.12.24.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jun 2021 12:24:34 -0700 (PDT) Received: by mail-il1-f172.google.com with SMTP id b9so9914020ilr.2 for ; Fri, 04 Jun 2021 12:24:34 -0700 (PDT) X-Received: by 2002:a05:6e02:de9:: with SMTP id m9mr5380481ilj.89.1622834673935; Fri, 04 Jun 2021 12:24:33 -0700 (PDT) MIME-Version: 1.0 References: <20210604092638.985694-1-ribalda@chromium.org> In-Reply-To: From: Ricardo Ribalda Date: Fri, 4 Jun 2021 21:24:23 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] tools/perf: Do not set a variable unless it will be used To: Peter Zijlstra Cc: Linux Kernel Mailing List , linux-perf-users@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter On Fri, 4 Jun 2021 at 11:36, Peter Zijlstra wrote: > > On Fri, Jun 04, 2021 at 11:26:38AM +0200, Ricardo Ribalda wrote: > > clang-13 triggers the following warning: > > > > bench/inject-buildid.c:351:6: error: variable 'len' set but not used [-Werror,-Wunused-but-set-variable] > > u64 len = 0; > > > > This patch sets the value to len only if it will be used afterwards. > > My vote would be to kill that warning, what absolute shite. My knowledge of llvm codebase is close to NULL, so it is much easier for me to "fix" the code. I would assume that the static analyser has found a magic condition where the previous if always returns false, and has managed to "optimize" the code. -- Ricardo Ribalda