From patchwork Sat Oct 27 00:53:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10657993 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 F0F105A4 for ; Sat, 27 Oct 2018 00:53:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3B662C9C1 for ; Sat, 27 Oct 2018 00:53:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1F662BBB2; Sat, 27 Oct 2018 00:53:40 +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=-7.9 required=2.0 tests=BAYES_00,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 D0F722BBB2 for ; Sat, 27 Oct 2018 00:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726415AbeJ0Jct (ORCPT ); Sat, 27 Oct 2018 05:32:49 -0400 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) 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=WptXaqKzOilBbBXuARJKF+ClrlgSWsdVLoH0WZF+AUw=; b=zsfSEbJH6zlHbqyhGA8OtuorYmMJ1ZTcyPBf9HjttyOcdB/elSifNW+EmYUJ7OvHDZ uxSFp4awzJ4wokTFqQDrYUMOAJ7niU1YrwK+4w6WZg6Z/03WvJ9FtEMd10nMTkY18dsO X4/U1wQ9vyGELjI48GSXznR+/EBZAe9W6i1kBGTPunBlaDwExSsFqYk5JSajnf4PJJFS +c0A9ARjQN10l1rf+zYGcX14Zb3UaG4y+vxXx6cpRtQsiUx0JxKvvzQfPSIg9bgenQhv YjOLj+4OiYxCJZIqQf2MzdQgu67/G3YNRO6FOqbHaxAtl18XFfmPEFQAWnZU8lWZ1tio WzxA== 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=WptXaqKzOilBbBXuARJKF+ClrlgSWsdVLoH0WZF+AUw=; b=OGETpzE/xkfL7TsQa7HwBUahnnF9cZ0MbarXrPYLDnIMAyHbu2aMwlNkBVLlm7Vt0r uvGgWju0AfjSvGL59PgKzIzSY1Jkg3EA5Oayp71GM7Aunk5sun5NTZuvGBx0DqCN11QL NRSudi9+zO2xcSy/DMrjVLGlTrAECIPoq49SgMJeHtDYrDOYEt7iVZfvxddnpsqZEDGy 4389Q+FTFZxMC+SedAoOKsVLoQbIffXXcuGLSp3qvc2uiY1TGd4Ok0QvRUV4DbxeZQ8r +oO37W/I98vamzUb2068j2ArMcuTup5d/LD0tiZG40MM5fNGk62UMEQ4QTKL6gB4xv48 csnA== X-Gm-Message-State: AGRZ1gL3CeOA3SpC1A2vQvwyqQ3whse6kNh+Jj6aZ+CLvbeLv1IBnxWE 1AR8HksOnN5Lmjz6sfYaEX9IZw== X-Google-Smtp-Source: AJdET5fcZ2MrapmeWs2JKLRvcI/7nHJVMk8igpOxtUBnmaJuVHvBnuKpeonYWGVsq134NXvttfrDjg== X-Received: by 2002:a1c:c708:: with SMTP id x8-v6mr7054264wmf.116.1540601615928; Fri, 26 Oct 2018 17:53:35 -0700 (PDT) Received: from pathfinder (62-64-249-96.dynamic.dsl.as9105.com. [62.64.249.96]) by smtp.gmail.com with ESMTPSA id x17-v6sm9669755wrs.84.2018.10.26.17.53.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Oct 2018 17:53:35 -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-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 --- 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