Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1161646pxb; Fri, 6 Nov 2020 02:35:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxytILO0Rw0VfV0/ieGM1/LbBgBNP3FMrfb07VvYGIbwp/C5kG/kNXpGAcJ+O7LW2Imw3Ep X-Received: by 2002:a17:906:c186:: with SMTP id g6mr1240532ejz.465.1604658952938; Fri, 06 Nov 2020 02:35:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604658952; cv=none; d=google.com; s=arc-20160816; b=OqpOCkaAKiwDbBk8G4O3nyaRuS9qSuRxxJmJaeNasBkkeLyNVpZ1gJuw246bmb4Wqa 2jlpbkgTf5DMGuJ3ku+1/2Ldc3Y8uudQKaReXbaEyepB7sjQ5xFplOqPewwYZvKHNYk7 BzXHcFviU9JA3pdlEy5zMkJmMjWH8U6QeUHyrRTQ/EmdoFDC6b/JJBh+NYw3TWs1OHMX uocVTAkFRCTOVn+SyvoQpdTo1A4wHwf30PfNpoDxAgtjtr2NYCObmzf1tw1Of+kYDazq FGIJcWBeHFYwILd23Uh4U/GktKtkuvkx68RbYdN/vLGBDxwL8wjUTBZ5OrMlOc67NmXQ WJVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:date:from:dkim-signature; bh=8N2IRuQnolyQXy5yxaGIniNO8dc/B+5yGSA8aD4EoDE=; b=Dpy9Xhd/BNCkataxAln4I3XU/i842qTFzDCTxr7G+4ZC4OFZCzJz0nG9KJ642+wjzt 38PLIaaHEptCXVsXZrC2FPkFvOz1r5Yi4ysRyAS1yA1hK1MpuF+O12mkiGy5n4J0eSSt DCkMNdS9gc82hSJG+fuNpupVw1gaVJSVASxIdXAcR3lb3h8OPVSDup2tBGsK1CsrR6GR 8pK8kiy42HLT3SDZfgbhNqvtK6CrKKtU4L065kqfD1LgER8OPWlg7NPEYIyvCYvJi4Yh WoBnCpsCFmvzasiW+B266ANWIctKQZKyyW/VUWrdCl64vl9iM/xnzEXhIr3fUplDZbwV fLlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lHdUzkWW; 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 f11si555510edj.402.2020.11.06.02.35.28; Fri, 06 Nov 2020 02:35:52 -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=lHdUzkWW; 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 S1726897AbgKFKbv (ORCPT + 99 others); Fri, 6 Nov 2020 05:31:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbgKFKbu (ORCPT ); Fri, 6 Nov 2020 05:31:50 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA1F9C0613D2; Fri, 6 Nov 2020 02:31:49 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id t11so717932edj.13; Fri, 06 Nov 2020 02:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=8N2IRuQnolyQXy5yxaGIniNO8dc/B+5yGSA8aD4EoDE=; b=lHdUzkWWoaJfy2mGDpg1jn0up1rtpy2t99CMXBhJL1ybYmJ6qBiRonnd51l4uq9mYX 0JNsxZ7a2CRcRDyqEIIJyclvj5m25kmBT1VF3N4ombJSB5m7h7fItCOZWW7buXm1oikF OGj1S/C1CYzDl2kGumLca52COUsUUNDUfu0SAEYvxipKbSQHhsemsHy2bSwfODyybUJm RnA7VzNHGmVAXkVO1cIuP6MyyImmyVokABJP3JZckjPkImdX86UZgAMUmSvFW2S9MIYf I/V9nm3O0T72AmTBG12TA7d5ot11IlFB/e2UCafPCIyelEq35U796axa6y/4C/zIahZ3 i11A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=8N2IRuQnolyQXy5yxaGIniNO8dc/B+5yGSA8aD4EoDE=; b=k5lmW0kTU+9u4yWuyMqFlBuMIpS2AS0xhysaoKbUNt7/XAoteBZd5o6x/byV/YdWFP cpNxpfEXGGtFNhjEC35+94KdUo829MiGiRhHN0xTSGgi68op/dOIP829JNAZyCuTsV7s zLXTQRnbwW0GQBPM7i8/dXRDEpVWoAYGQ9agYzlp5tTC/nJfTMBx19+ArSvaS6kQ1hXl xZG7NRKrrQi0vkZTiQoxk1stnRA757JBArPC9f2cVDcyLLSXygUxrzHKlWvFJoCwJa6B eO2Y5JszUjOpCU6xZLs0IxT6qz9WvSNvVnknMFEEjyIs6h8SN9h0ertJs9/D/XyjgmoX zufQ== X-Gm-Message-State: AOAM533fJD4w4L++Ls5nMi6Qf1NUqjQeEUCHoqA9jEWTSLQLIDsFdBON kzfEeUDnUVDIrbs3qJd9WLY= X-Received: by 2002:aa7:cac2:: with SMTP id l2mr1277712edt.141.1604658708559; Fri, 06 Nov 2020 02:31:48 -0800 (PST) Received: from felia ([2001:16b8:2d20:9d00:e580:adb5:1ef:950d]) by smtp.gmail.com with ESMTPSA id h4sm696552edj.1.2020.11.06.02.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 02:31:47 -0800 (PST) From: Lukas Bulwahn X-Google-Original-From: Lukas Bulwahn Date: Fri, 6 Nov 2020 11:31:46 +0100 (CET) X-X-Sender: lukas@felia To: Sudip Mukherjee cc: Lukas Bulwahn , Balbir Singh , 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 Subject: Re: [linux-safety] [PATCH] taskstats: remove unneeded dead assignment In-Reply-To: <6ab2415b-0642-16ee-4be0-c909e07e7565@codethink.co.uk> Message-ID: References: <20201106062210.27920-1-lukas.bulwahn@gmail.com> <6ab2415b-0642-16ee-4be0-c909e07e7565@codethink.co.uk> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Nov 2020, Sudip Mukherjee wrote: > 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) { I thought about that as well; and I did not like that because of the ugly line break in this condition. I did not try but I bet (a beverage of your choice) that the object code remains the same also for your suggested patch. Try to disprove my claim and possibly earn yourself a beverage when we meet... Lukas