From patchwork Mon Jan 21 00:54:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10773305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BCCB1390 for ; Mon, 21 Jan 2019 08:22:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F084729DC8 for ; Mon, 21 Jan 2019 08:22:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4FFD29EEB; Mon, 21 Jan 2019 08:22:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FB8529DC8 for ; Mon, 21 Jan 2019 08:22:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729300AbfAUIW1 (ORCPT ); Mon, 21 Jan 2019 03:22:27 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:32901 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729916AbfAUIW0 (ORCPT ); Mon, 21 Jan 2019 03:22:26 -0500 Received: by mail-wr1-f68.google.com with SMTP id c14so22222881wrr.0 for ; Mon, 21 Jan 2019 00:22:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=g/wBSYFj3l9yPAKISLJz158vlsYmZp73WHXmjEKdO4g=; b=PD8/VSHVPUfRG5byWoJPyF97v1LgvRm+EauI/ObnYoMJ61bhLXG04xfpmfdhBmeYCq PiI09iPx58fo0FJaYuJ5bqnHq0PULjYUmn0KLnN7xkkpI+6JnntqHRtRVAjB386yJc/V h8VfoJUMG6CoYYWW7p7a8r2uZoBhEf0AP0gyNB1vN91lY5yQ8QuBYw0LLtvufAxyPLqN +Q3MVT8hhB2yXYEB7EG/Ew61xQ4OJHF7DbudbkZ8AL8QVMvH1cqogWuEu4pewF3XfZWz b7DsJEGBzNPRreimfYr2ZU6tRK3B62CnV9ng2LMDYghdo0r4TTmyRqgE4geyNPNSVupl Y21g== 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:mime-version :content-disposition:user-agent; bh=g/wBSYFj3l9yPAKISLJz158vlsYmZp73WHXmjEKdO4g=; b=sEYQQBtMsXrWDmfjE+EOTWSH8nhzVeVzds4YRV37byffc+Nkf/St7fS/GC13xiT6Co NwFwZ2f1+q+KZX8RERIB3vzCCjlhjtbRhhcfvYAoqYAcxdKXt572erYlt/Hid1nyuCqF yfas06KV3/U1okSAEZI2O7H5RrmDrGWnes0t+X0RIpktiGFdWkDhWcXNRS+lPnb5VOc0 PJVtLdPldFbeWrzOrnfw03XSSwz6dHpu8/oeNzulirP9mtazRt671shuW4WgIwgqrPY2 4Nq5dh5wz9hkjLNBdE69eMOAennCs09UxWIA61Uaii6mbmd9RmC6tBspGFyGnccI+gzt xj2w== X-Gm-Message-State: AJcUukcOKnctUz+TYwe2msc0ydxkiHad+kthGlpkJrN+n/foALz6iVpc ERcz9QKMyjA7GWh7BIpUFka2CsMENDlCpw== X-Google-Smtp-Source: ALg8bN5FLwq+9mgsC9v4ieSBocJ+33oo+LPA1EKv/A0q1g4+qt2B6gz5Ml7Ek1YkxEFZliqD5Mu3Pg== X-Received: by 2002:adf:f984:: with SMTP id f4mr25910313wrr.234.1548032070169; Sun, 20 Jan 2019 16:54:30 -0800 (PST) Received: from pathfinder ([90.222.17.17]) by smtp.gmail.com with ESMTPSA id w80sm69705265wme.38.2019.01.20.16.54.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 20 Jan 2019 16:54:29 -0800 (PST) Date: Mon, 21 Jan 2019 00:54:29 +0000 From: Phillip Potter To: dushistov@mail.ru Cc: amir73il@gmail.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH v5 02/09] ufs: use fs_umode_to_dtype() helper Message-ID: <20190121005429.GA32329@pathfinder> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace switch statement with common lookup table implementation - file systems that use the same file types as defined by POSIX do not need to define their own versions and can use the common helper functions decared in fs_types.h and implemented in fs_types.c Signed-off-by: Amir Goldstein Signed-off-by: Phillip Potter Reviewed-by: Jan Kara --- fs/ufs/util.h | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/fs/ufs/util.h b/fs/ufs/util.h index 1fd3011ea623..8c7759860739 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -158,34 +158,7 @@ ufs_set_de_type(struct super_block *sb, struct ufs_dir_entry *de, int mode) if ((UFS_SB(sb)->s_flags & UFS_DE_MASK) != UFS_DE_44BSD) return; - /* - * TODO turn this into a table lookup - */ - switch (mode & S_IFMT) { - case S_IFSOCK: - de->d_u.d_44.d_type = DT_SOCK; - break; - case S_IFLNK: - de->d_u.d_44.d_type = DT_LNK; - break; - case S_IFREG: - de->d_u.d_44.d_type = DT_REG; - break; - case S_IFBLK: - de->d_u.d_44.d_type = DT_BLK; - break; - case S_IFDIR: - de->d_u.d_44.d_type = DT_DIR; - break; - case S_IFCHR: - de->d_u.d_44.d_type = DT_CHR; - break; - case S_IFIFO: - de->d_u.d_44.d_type = DT_FIFO; - break; - default: - de->d_u.d_44.d_type = DT_UNKNOWN; - } + de->d_u.d_44.d_type = fs_umode_to_dtype(mode); } static inline u32