From patchwork Sat Oct 27 00:53:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10657995 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 30DB0180E for ; Sat, 27 Oct 2018 00:53:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23BDA286E5 for ; Sat, 27 Oct 2018 00:53:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F4132BBB2; Sat, 27 Oct 2018 00:53:41 +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 97AE42C4A6 for ; Sat, 27 Oct 2018 00:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726529AbeJ0Jcu (ORCPT ); Sat, 27 Oct 2018 05:32:50 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33144 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725828AbeJ0Jcu (ORCPT ); Sat, 27 Oct 2018 05:32:50 -0400 Received: by mail-wr1-f65.google.com with SMTP id u1-v6so2978560wrn.0 for ; Fri, 26 Oct 2018 17:53:38 -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=y5r68PY8UFFLRUTTNh+yHW7vn1SZVaoDg2UPXDkZOJk=; b=bvvjxIEBspxkjV/6B2ROO/2uZctPD6jDyjzWsUYRlFlJVUfHit94Cinl4sHggiAW7K OZIc6Nzh3pY0scfwlYCc49xiMpKbMd0UWMzVjY6N2bZov4B3I6njTJAsbcLrng/VJ+hi bZJeax+x/UNld62Xh1xcUWXLsVNZkVEVg8lJAWOon2h0MFErt+u0dZK7ufadn/9dMUxt MOPQa42KkZhNi4qtv89E/0aF7ALIN9QY4mg/35OOOpeSGI++JLQTW5TQ7o+qnS4/Stgy gMGf9ebPh+BinvTlWN1zAqJ9SPUJMi8u4au3sUp4pYJfah4rv35SpfAHkX6xjtviGNrI E4iA== 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=y5r68PY8UFFLRUTTNh+yHW7vn1SZVaoDg2UPXDkZOJk=; b=mjhx2BRlJzvftZrqT6kts1WxUANgOQRMBjfcXC1s7mO6EaRB17B8R/MN9IR/es6rSZ N9pjSMozTVKwLk+OA1jg3JXUEKQq575q98xdnH4PeWuIH1n6UEt3g3bxHEyivsE3ycxB iIgv2kj4NWr2SGSgqnvl98lL1XdYCA3bbdZxAJN8j5RtwZqmGc6c14IQmCTQ4rjjUL1J LcQI4Js3lHjmpiQ6NtP0YqI8hGoqbyvmsqpgs3FT0sN62EWVUWKip+Gb6dNnzfS0jFZ3 FIOfhl/BCuc4mkGW15BKg45rlkYlY7kqP76qfiSae+7j8PXYuwLqTULsy2jA2qq34alh iu4Q== X-Gm-Message-State: AGRZ1gJW54PQqhdnLKc8n9nq9cSP2+PxM/3TZE+M7rgomeOA5e8PFwFF YODiLFwrnTLPDYffEkkfOX4ooX9xJlEG0Q== X-Google-Smtp-Source: AJdET5fIrSO37aBEefBJI5YabnXjPiOatRC2ATcHSU/8bnzHwKRw1gn8+XH+3ViQpZKZJ34OzztREg== X-Received: by 2002:adf:b593:: with SMTP id c19-v6mr7725290wre.223.1540601617147; Fri, 26 Oct 2018 17:53:37 -0700 (PDT) Received: from pathfinder (62-64-249-96.dynamic.dsl.as9105.com. [62.64.249.96]) by smtp.gmail.com with ESMTPSA id 126-v6sm4281159wme.48.2018.10.26.17.53.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Oct 2018 17:53:36 -0700 (PDT) Date: Sat, 27 Oct 2018 01:53:35 +0100 From: Phillip Potter To: linux-fsdevel@vger.kernel.org Cc: amir73il@gmail.com, viro@zeniv.linux.org.uk, slava@dubeyko.com Subject: [RFC][PATCH v3 03/10] hfsplus: use fs_umode_to_dtype() helper Message-ID: <20181027005335.GA9947@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 if/else statements 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: Vyacheslav Dubeyko --- fs/hfsplus/dir.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index f37662675c3a..7b798a46c8ac 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -223,7 +223,6 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) break; } else if (type == HFSPLUS_FILE) { u16 mode; - unsigned type = DT_UNKNOWN; if (fd.entrylength < sizeof(struct hfsplus_cat_file)) { pr_err("small file entry\n"); @@ -232,21 +231,10 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) } mode = be16_to_cpu(entry.file.permissions.mode); - if (S_ISREG(mode)) - type = DT_REG; - else if (S_ISLNK(mode)) - type = DT_LNK; - else if (S_ISFIFO(mode)) - type = DT_FIFO; - else if (S_ISCHR(mode)) - type = DT_CHR; - else if (S_ISBLK(mode)) - type = DT_BLK; - else if (S_ISSOCK(mode)) - type = DT_SOCK; if (!dir_emit(ctx, strbuf, len, - be32_to_cpu(entry.file.id), type)) + be32_to_cpu(entry.file.id), + fs_umode_to_dtype(mode))) break; } else { pr_err("bad catalog entry type\n");