From patchwork Tue Oct 23 20:19:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10653605 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 76DC214BD for ; Tue, 23 Oct 2018 20:20:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FFB12A3E4 for ; Tue, 23 Oct 2018 20:20:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 544582A3EA; Tue, 23 Oct 2018 20:20:04 +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 AB7E92A3E5 for ; Tue, 23 Oct 2018 20:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728897AbeJXEo4 (ORCPT ); Wed, 24 Oct 2018 00:44:56 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51834 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727726AbeJXEoz (ORCPT ); Wed, 24 Oct 2018 00:44:55 -0400 Received: by mail-wm1-f67.google.com with SMTP id 143-v6so3069580wmf.1 for ; Tue, 23 Oct 2018 13:19:58 -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=2rgD7RkIz8RrksTmcPFlaMjrDpZ6eKiDDFJ0lLZWZXQ=; b=X4sjJDFAynbd9O8BW0ZnALfYUXzqRyP+mt7/l5CCldfAf1ieebi23SSA7WpxTeP7g5 Y2bCbEHpbGidoESXsO5P2TrWFsioKjjzzyrMSAeQqSzVYhZMhh5AAxMhUbxU1aHLrROk reQX6I5blXzZ3AMjCpW+ggIJfUWTvAUm+IGFmXDznl/IZ0/NGXUvhQQt2GblGwu8jClM caaOgFyUv5JJBhlcPBY/K9c3JlF3PYtlFA1hrbWI8mL5VvU8d4ES0sf42gCpTiA6/nH4 YEnjtd+ZwrLwofNQ3gL2zBzpmpaauqvPCfuY4YcBunU/a7Diw/RXuThZwWRrIVOX44SC cRLQ== 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=2rgD7RkIz8RrksTmcPFlaMjrDpZ6eKiDDFJ0lLZWZXQ=; b=NaGvHl6WERt0RJU9MrsrBHf7oor0xELqRv+1cShRvLL55jYZM3FxUmo+yJ9mDTsVq8 8lXqeMMWvcLbeYli16NUeNCewk7UBs6YBzvW+WuZE3qE1csMrghotXLB2k+IG/Rj3YFS /rPv0RP1ydDz8cbYVn/i/PxEXwzhh+icoAmWX1YPa+OoYrJLIYcnNn16eQfJDsg1+LzR IYLjr157GbzTrIaWKcoGw0OIcNEwyoE3Lp2veL9q/1JCorGOc+KoRKKgfAjTiVS3uATP 5GXAGzhtSMC0IUONnF/pcWawORrJs/c2dunoQj9jKz7pazkyQ2SEPq2X/9BPtT3jkmXm qfew== X-Gm-Message-State: ABuFfognZ65q0girPcq8HrSQ2tMoYa+wJaNBjN4Hs6Hyw+CX5YWFDlKl ygWCk3WAIpo1JcEw7e8kSdjyyfSBCq6B0A7M X-Google-Smtp-Source: AJdET5dOnlEezDBSrlCRxBFT01dsGPmoMnL4LUxnbZXJjtMKZtVvz697LGaExXIKYvQsLfn4mTxGdg== X-Received: by 2002:a1c:1a45:: with SMTP id a66-v6mr5327821wma.20.1540325997514; Tue, 23 Oct 2018 13:19:57 -0700 (PDT) Received: from pathfinder (62-64-249-96.dynamic.dsl.as9105.com. [62.64.249.96]) by smtp.gmail.com with ESMTPSA id h78-v6sm3292578wmd.4.2018.10.23.13.19.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 13:19:56 -0700 (PDT) Date: Tue, 23 Oct 2018 21:19:56 +0100 From: Phillip Potter To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, amir73il@gmail.com, viro@zeniv.linux.org.uk Subject: [RFC][PATCH 03/10] hfsplus: use fs_umode_to_dtype() helper Message-ID: <20181023201956.GA15701@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. Original patch written 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");