Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp584938ybg; Fri, 12 Jun 2020 09:12:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2cyUzGf8sZIYCuZreXGk/UuS1cbzu2BvjzppNHBTlzrTbxxpTQ88LhO9VBhPETs4ziteG X-Received: by 2002:a17:906:f49:: with SMTP id h9mr14623076ejj.155.1591978356753; Fri, 12 Jun 2020 09:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591978356; cv=none; d=google.com; s=arc-20160816; b=LaTZK630LfLzdiLcXitUI8xWIdlK/LFCvkXSKzq/vDN/s9ruVSHNJDfXpiDi/JPXb4 iLjrKbTHTnOqxW/INSmGqRqyiu/qQxkYkvYywaqfMaStPV+P8/jBxiB6o/aLEGtOcyCm IXXGVXihEllVthsQJOUHx9yaPxfMvH5LRlN0csU39hz/epOAtmmtPO9vSmcnr8Q9WyRL rhopztKEeJue4H3DpVnuUsdkwqJjsoMCj3HGfUxFAKFHHyaLuQj9Q8laKNuWN3d3Vy3m nPW77wMemBN5G32jaqOlAcEJKVmrW/+rnKXogrfhnB1Tqku2/PI12g4WdN3a6C+3gLVT 7KXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xGowqnfFw5R0e+Qkd5MSY7h9qfsgL+NMoQac/0huSiE=; b=rkSwQHAEbLQ2G3ECfJ3Y07MehpxdZ9xSaaipgb2dyR17aKpqjfG4Pg5bSG9u1nKcHg bJPtfeEW0GkdgoNvChau4UW+3+7EGioYbdr/NKVstVQw8pOGQVnMi4IgLHimJiFU+Pl+ BBUfF5OW/DT8O7Kv80F8ee94xq6BXIp9Xf3GtXNte74RCMMD5Cc81wPOWKWUNN5Cj1Cc iJW8+6Mb446f3sKxXcTLB2QsUTuoD1iQ2bxbV8xBQDwjL85uTWHrrnd8WlUAImehFIE/ IPoEwMXr56yQDjuArwqHSf3gUb1uopWush7/N3s9kgk1UAWDTvcsmU5qrPZRwRYq7E3s Kj4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LWM0Jgqe; 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 dk14si3851166edb.0.2020.06.12.09.12.14; Fri, 12 Jun 2020 09:12:36 -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=@gmail.com header.s=20161025 header.b=LWM0Jgqe; 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 S1726341AbgFLQKF (ORCPT + 99 others); Fri, 12 Jun 2020 12:10:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgFLQKE (ORCPT ); Fri, 12 Jun 2020 12:10:04 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C90E8C03E96F; Fri, 12 Jun 2020 09:10:04 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id i4so4051153pjd.0; Fri, 12 Jun 2020 09:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xGowqnfFw5R0e+Qkd5MSY7h9qfsgL+NMoQac/0huSiE=; b=LWM0JgqePgHG1PtiYO/tQhhZ1IXZhDY688eqkDRtu1G1KB+lncE7qt6C/K+OD2wmIo tev4g5xZQfGKLtZ0hvJbO+hFbxh7VtYJUr0VfhammcNc+16YdKyPEoDrU+UqTTNm7XLq mekKCMO+v1GtAxaPyZszhPsElYm4alT9pqHosUEB+yoz/ipvIZkjuTReR1HFg5aPgTIp YUI/maaYipbxTTfA9mf7qWkSnmRZP3EbkWmXiOssuTHB6qN6L2YJ+0pm2Kt3lMpONx62 RUYKiVwKxZdPpFIkevS+tVZYMrn24QAyZsQIk6WxXsFgGDP+UxyUvpPcUqHyzBftA3Xm toIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xGowqnfFw5R0e+Qkd5MSY7h9qfsgL+NMoQac/0huSiE=; b=FvxgINoX7u0GGrWc8QdTTi8QI6leOgUe44hadKgm+rwUTPb0EZJ56WE+qUO27Ha1wb 0dmLuHztCuPADe3k8IU0YgykqQboVnCw/nsi2f/yJVyB3oTGcQOczdElkcYZIUZkQUqO loFqiIgco6UY4UL04betue9TrGiOD1K5ZbZEeXcXrMOipAHBvDuwnfQarfiNZLtXKhQ4 u1Sy+n26zXFEUDLG72AfzgUjn16dLCgVXc0RYT1Fmd12xhuxg4tHn09tDsNFfV5rH1l7 kjmC8dyb5qz/0iYDQNCdB1ZSEoqIfbRyMwLkZWACc8ve+XyIk5BJH3LKhCDn5s2ZxTAe VFOQ== X-Gm-Message-State: AOAM532kQlNOjZUZrRkh06c9BKEjmQQ5c5DdAHxqe9RyZMU2zzB6YMRu gTZJVylgclVUPrk+qOdT8No= X-Received: by 2002:a17:902:b718:: with SMTP id d24mr11541086pls.185.1591978204151; Fri, 12 Jun 2020 09:10:04 -0700 (PDT) Received: from Smcdef-MBP.lan ([103.136.221.72]) by smtp.gmail.com with ESMTPSA id x1sm5794879pju.3.2020.06.12.09.10.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jun 2020 09:10:03 -0700 (PDT) From: Kaitao Cheng To: adobriyan@gmail.com, Markus.Elfring@web.de Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, songmuchun@bytedance.com, kernel-janitors@vger.kernel.org, Kaitao Cheng Subject: [PATCH v2] proc/fd: Remove unnecessary {files, f_flags, file} initialization in seq_show() Date: Sat, 13 Jun 2020 00:09:46 +0800 Message-Id: <20200612160946.21187-1-pilgrimtao@gmail.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'files' will be immediately reassigned. 'f_flags' and 'file' will be overwritten in the if{} or seq_show() directly exits with an error. so we don't need to consume CPU resources to initialize them. Signed-off-by: Kaitao Cheng --- v2 ChangeLog: 1. Fix some commit message 2. Remove unnecessary f_flags initialization fs/proc/fd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/proc/fd.c b/fs/proc/fd.c index 81882a13212d..d3854b76e95e 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c @@ -19,9 +19,9 @@ static int seq_show(struct seq_file *m, void *v) { - struct files_struct *files = NULL; - int f_flags = 0, ret = -ENOENT; - struct file *file = NULL; + struct files_struct *files; + int f_flags, ret = -ENOENT; + struct file *file; struct task_struct *task; task = get_proc_task(m->private); -- 2.20.1