Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3638175pxb; Mon, 9 Nov 2020 17:12:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJXTNx55ue8e14/oihKJoPnIkK+MjgwoxGu4MC+QjUiHA/9YmGs+CGArZhfAgLQ0R2KP2C X-Received: by 2002:a17:906:40cb:: with SMTP id a11mr18714055ejk.217.1604970759832; Mon, 09 Nov 2020 17:12:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604970759; cv=none; d=google.com; s=arc-20160816; b=KpLEKdZM9emUvRDKYWDu+tySH1YJpvqkwDDvAhdQL3Y2fM0mNrI2FzL+PQJmDGx4Wn 1jK1tMH5Hq9M47diV64fK8seKD64ausurq/lDZRKUrecWP7rU/fRq+V8es7BoLyCaRTW gXzEIOVi+7yHJIDNuZ424aUgE2LWgkpZJMjaYcyPpPoSEGbML+uW/6cWwA+0jF7wu+/S Y3eWtPp/I2XhhVype45+fCpVq/2Djed54KGCnHrH+CRAh2MW63Ut3xcb8r/xnyN16iIH pmiPe87pFMXUxtUk5j3RlageSdjkgptJ4V0hHTbqvHF980A3sMUOeDtz0LP42w3zkFJI e2Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jfYrdTPKMZbK96SOWjVC+rX+6K1DHm/KzMlUaGqdCkw=; b=P/B5BGeacFeuiE4AimFS319PB4T26UVTXsXzrS+lBid/xW3/JU1KcmjfS+qc9H9ogG CBUMQKCZV23oLe9bEK5DPSX3l/1IguzmsJvHM7BkYA2Xs5pL0cC4oT1i4nqwB1ZMN5re QZYuozZWpBhDGySzmLETEsSNi6qGuPeJ0ubpTCxs/jOm74erLTsH4UsJ4eBbNxW6KsGz DmhonXwrMjJBuGWhgWMTdD3MZNXczGdB6xZFVcbkRUcyCJhdObcqDGt2kfPkm5AzDcaE wqWnjpQaFHOOnGKbPNhauvseGWsW+/Ko9nTRJsXDo8Ku4N667S1NYxqwO7z9lBtMbozK s7Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pUdpifgo; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si8369814ejc.179.2020.11.09.17.12.17; Mon, 09 Nov 2020 17:12:39 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=pUdpifgo; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731151AbgKJBIU (ORCPT + 99 others); Mon, 9 Nov 2020 20:08:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727311AbgKJBIT (ORCPT ); Mon, 9 Nov 2020 20:08:19 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9709C0613CF; Mon, 9 Nov 2020 17:08:19 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id 11so9977575qkd.5; Mon, 09 Nov 2020 17:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jfYrdTPKMZbK96SOWjVC+rX+6K1DHm/KzMlUaGqdCkw=; b=pUdpifgoK3w/lahMuT6WcZmrX4aQ2ovlJSJoTrIARtJQbPBh83RGgcVvTlBrAsaUV5 u8Vk+QKxnbN7lKUsNHc4qJxvQq3P2iPRLc4GFr7foKh/io6u6OlPuBetXNzJdFMYUwcB SUfer6LTAEtgrkjvorvT+2Vg5kW082G8yBNdg8M3c1EhYm3l8A1zBWbRBSIgaC0BvfS8 CG0Os63C5a0pOtHwc6FF2Gl6eS+0yecZPNb/a58bWNx7yj7+xunAZeUNGDFUXcgorjTV lRlnHSxKw4LHtbs241np/7yGP77pdl7x305N2DAIcJaI+pyn2Fn3aTcRcPGH12u17m1m d0YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jfYrdTPKMZbK96SOWjVC+rX+6K1DHm/KzMlUaGqdCkw=; b=hLTL4HXhQoANiBkURr+Jo9c29pL9HDNFd54BFhXxpdhizFGyptelhNvwg18orp50Ve 72Dy7I2M0UKWb/aJaYjIaGIFGvJ/LXI9Lg5scvCyFn73uCS2ztN4cCErA40kZUO/PJe0 sKIfZtqBjs+B1pWnNSQaaUsVnwmJaON/naAAeaaL5Lg+cotnnzLJlDT57WN2IKCcNiUh aRpQ1nZrvHLipkNweoKrIvLEvV+DjEoOrWm4oyi6jWKyYduewTrVPyEKBz9U/+5Mg4oG IGDZyrwKHhPsMaOdkJQEQdv9La1XffzSQQJP9FGKrOqS9zlSWyE/OoWne3lfWkvVLSJe 8ndA== X-Gm-Message-State: AOAM533iNhjIj7FFNqBDEhk//mwagrWdIQ1sdiREX1UwTt/aHpaqw7zQ ftwZjfITCctb19S3SpEec10= X-Received: by 2002:a37:8c9:: with SMTP id 192mr7524631qki.428.1604970498896; Mon, 09 Nov 2020 17:08:18 -0800 (PST) Received: from ubuntu-m3-large-x86 ([2604:1380:45f1:1d00::1]) by smtp.gmail.com with ESMTPSA id k3sm6774156qtj.84.2020.11.09.17.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 17:08:18 -0800 (PST) Date: Mon, 9 Nov 2020 18:08:16 -0700 From: Nathan Chancellor To: Lukas Bulwahn Cc: Luis Chamberlain , Kees Cook , Iurii Zaikin , linux-fsdevel@vger.kernel.org, Tom Rix , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-janitors@vger.kernel.org, linux-safety@lists.elisa.tech, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sysctl: move local variable in proc_do_large_bitmap() to proper scope Message-ID: <20201110010816.GA2018112@ubuntu-m3-large-x86> References: <20201109071107.22560-1-lukas.bulwahn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201109071107.22560-1-lukas.bulwahn@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 09, 2020 at 08:11:07AM +0100, Lukas Bulwahn wrote: > make clang-analyzer caught my attention with: > > kernel/sysctl.c:1511:4: warning: Value stored to 'first' is never read \ > [clang-analyzer-deadcode.DeadStores] > first = 0; > ^ > > Commit 9f977fb7ae9d ("sysctl: add proc_do_large_bitmap") introduced > proc_do_large_bitmap(), where the variable first is only effectively used > when write is false; when write is true, the variable first is only used in > a dead assignment. > > So, simply remove this dead assignment and put the variable in local scope. > > As compilers will detect this unneeded assignment and optimize this anyway, > the resulting object code is identical before and after this change. > > No functional change. No change to object code. > > Signed-off-by: Lukas Bulwahn Reviewed-by: Nathan Chancellor > --- > applies cleanly on v5.10-rc3 and next-20201106 > > Luis, Kees, Iurii, please pick this minor non-urgent clean-up patch. > > kernel/sysctl.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > index ce75c67572b9..cc274a431d91 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -1423,7 +1423,6 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, > void *buffer, size_t *lenp, loff_t *ppos) > { > int err = 0; > - bool first = 1; > size_t left = *lenp; > unsigned long bitmap_len = table->maxlen; > unsigned long *bitmap = *(unsigned long **) table->data; > @@ -1508,12 +1507,12 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, > } > > bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); > - first = 0; > proc_skip_char(&p, &left, '\n'); > } > left += skipped; > } else { > unsigned long bit_a, bit_b = 0; > + bool first = 1; > > while (left) { > bit_a = find_next_bit(bitmap, bitmap_len, bit_b); > -- > 2.17.1 >