From patchwork Wed Apr 15 04:47:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Guzik X-Patchwork-Id: 6218731 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 850849F1C4 for ; Wed, 15 Apr 2015 04:48:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B27FD20361 for ; Wed, 15 Apr 2015 04:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1AB8320377 for ; Wed, 15 Apr 2015 04:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932252AbbDOErs (ORCPT ); Wed, 15 Apr 2015 00:47:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51205 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbbDOErp (ORCPT ); Wed, 15 Apr 2015 00:47:45 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 740468E791; Wed, 15 Apr 2015 04:47:44 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3F4lfpN009775; Wed, 15 Apr 2015 00:47:42 -0400 From: Mateusz Guzik To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs/file.c: remove useless xchg and NULL check in close_files Date: Wed, 15 Apr 2015 06:47:40 +0200 Message-Id: <1429073260-17470-1-git-send-email-mguzik@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the table is about to be freed, there is no reason to set file pointer to NULL on closing. At this point open_fd map is supposed to indicate whether a file is installed, so NULL-checking it is unnecessary. Signed-off-by: Mateusz Guzik --- fs/file.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/file.c b/fs/file.c index 93c5f89..35a024a 100644 --- a/fs/file.c +++ b/fs/file.c @@ -364,11 +364,8 @@ static struct fdtable *close_files(struct files_struct * files) set = fdt->open_fds[j++]; while (set) { if (set & 1) { - struct file * file = xchg(&fdt->fd[i], NULL); - if (file) { - filp_close(file, files); - cond_resched_rcu_qs(); - } + filp_close(fdt->fd[i], files); + cond_resched_rcu_qs(); } i++; set >>= 1;