From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f68.google.com ([209.85.128.68]:40207 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725828AbeJ0Jcs (ORCPT ); Sat, 27 Oct 2018 05:32:48 -0400 Received: by mail-wm1-f68.google.com with SMTP id b203-v6so2912401wme.5 for ; Fri, 26 Oct 2018 17:53:36 -0700 (PDT) Date: Sat, 27 Oct 2018 01:53:34 +0100 From: Phillip Potter To: dushistov@mail.ru Cc: amir73il@gmail.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH v3 02/10] ufs: use fs_umode_to_dtype() helper Message-ID: <20181027005334.GA9940@pathfinder> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- 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 -- 2.17.2