Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1169821pxb; Fri, 6 Nov 2020 02:52:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQcnQ1M1rLZXLMZ857J4Olmbl75KBMV7p7AIp6cycfa5kBeNQMQaU47F4hQcMc9crZ1cZq X-Received: by 2002:a50:d583:: with SMTP id v3mr1353829edi.125.1604659940006; Fri, 06 Nov 2020 02:52:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604659939; cv=none; d=google.com; s=arc-20160816; b=y3YFb08v0C/b6oxGI7+hVQhig4OGPDARK2jiNM+WZn6Yc7Lwb4bbCsvJMjf38ORQUB Dr4hbWoTsOmfdyGm5ADeKUyktI4Fl0NHhv14S/LBNR8STtbOjKvMV54M9Gr/bMcUXAr7 GIh5ZEa28hN6akUbEan7SjK+0B8sV0RBBqn07Mvzzuli6R8FWHTHOgINZ8oGL2K+Hh7d iX0MiJO50WcMLIyLDfG10GXYoEGyK6yyh7GoxNkOep6EN62TRitYETRBFkosgqRauV/D SQWcwgfhaZ/LYguEUyGOybF/QXlYEbsNPynxEJbLMo0YkS9GbsngZ55jRQ/3cPynjR2H 6SfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=0UD6a0pllSjF3i06FlsmAGucWjUbMNUG6fD2RH/WgWg=; b=coZW6egsggC9sAinvZvvzAC2UPGCvQMKzgOHWRY/AKtGkFrzH0+XMLCAyvKJnFFlCm JN1/soYVpvEiJS363vvZauk6WTlCiUxJ51IS+nXRY608CwAHYOSfQUgDtQpkt4xLZs45 54K0Um4a1vQql9SZl3ly6bU9TQvPXrJKrRyOQ2bKcEEtm7zR2wHVoXhnWK1xyUBptePm lJl13vw4AzW0pHxQUs21Z4tJsc+5SmPNxcjYElmQ5lP7bhSciiy+EhMt7fY6wrC4GgXI rnWn38G8SwI9EfAXbUVrXkzKSCyfoF6AjtnYUEQvQ9rNeZlhhAxNpr9cVemtiSpUUiwK ZPig== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si540759ejn.227.2020.11.06.02.51.57; Fri, 06 Nov 2020 02:52:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbgKFKuZ (ORCPT + 99 others); Fri, 6 Nov 2020 05:50:25 -0500 Received: from imap3.hz.codethink.co.uk ([176.9.8.87]:34498 "EHLO imap3.hz.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgKFKuZ (ORCPT ); Fri, 6 Nov 2020 05:50:25 -0500 X-Greylist: delayed 1489 seconds by postgrey-1.27 at vger.kernel.org; Fri, 06 Nov 2020 05:50:23 EST Received: from host-92-5-241-147.as43234.net ([92.5.241.147] helo=[192.168.1.13]) by imap3.hz.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1kayvz-00071a-Sl; Fri, 06 Nov 2020 10:25:31 +0000 Subject: Re: [linux-safety] [PATCH] taskstats: remove unneeded dead assignment To: Lukas Bulwahn , Balbir Singh Cc: Tom Rix , Nathan Chancellor , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-janitors@vger.kernel.org, linux-safety@lists.elisa.tech, linux-kernel@vger.kernel.org References: <20201106062210.27920-1-lukas.bulwahn@gmail.com> From: Sudip Mukherjee Message-ID: <6ab2415b-0642-16ee-4be0-c909e07e7565@codethink.co.uk> Date: Fri, 6 Nov 2020 10:25:30 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201106062210.27920-1-lukas.bulwahn@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lukas, On 06/11/2020 06:22, Lukas Bulwahn wrote: > make clang-analyzer on x86_64 defconfig caught my attention with: > > kernel/taskstats.c:120:2: warning: Value stored to 'rc' is never read \ > [clang-analyzer-deadcode.DeadStores] > rc = 0; > ^ > > Commit d94a041519f3 ("taskstats: free skb, avoid returns in > send_cpu_listeners") made send_cpu_listeners() not return a value and > hence, the rc variable remained only to be used within the loop where > it is always assigned before read and it does not need any other > initialisation. > > So, simply remove this unneeded dead initializing assignment. Might be better to remove 'rc' completely as it is only used for the if condition now. diff --git a/kernel/taskstats.c b/kernel/taskstats.c index a2802b6ff4bb..63541f1ae04a 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -113,11 +113,10 @@ static void send_cpu_listeners(struct sk_buff *skb, struct listener *s, *tmp; struct sk_buff *skb_next, *skb_cur = skb; void *reply = genlmsg_data(genlhdr); - int rc, delcount = 0; + int delcount = 0; genlmsg_end(skb, reply); - rc = 0; down_read(&listeners->sem); list_for_each_entry(s, &listeners->list, list) { skb_next = NULL; @@ -126,8 +125,8 @@ static void send_cpu_listeners(struct sk_buff *skb, if (!skb_next) break; } - rc = genlmsg_unicast(&init_net, skb_cur, s->pid); - if (rc == -ECONNREFUSED) { + if (genlmsg_unicast(&init_net, skb_cur, s->pid) == + -ECONNREFUSED) { s->valid = 0; delcount++; } -- Regards Sudip