From patchwork Thu Oct 8 11:49:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byongho Lee X-Patchwork-Id: 7352251 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EED259F1D5 for ; Thu, 8 Oct 2015 11:49:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19F8820617 for ; Thu, 8 Oct 2015 11:49:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C6F120610 for ; Thu, 8 Oct 2015 11:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756389AbbJHLtn (ORCPT ); Thu, 8 Oct 2015 07:49:43 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:36558 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753926AbbJHLtm (ORCPT ); Thu, 8 Oct 2015 07:49:42 -0400 Received: by pablk4 with SMTP id lk4so53169924pab.3 for ; Thu, 08 Oct 2015 04:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=G2MuDtmsiROeSz2ijgDcZMC/ziMhuJwW32wj8fc3UrY=; b=FNXdcaAUPmAshflKPL5Em1MEcvgqEm8+QTKfTjCOILNGw2VVkRYrrBqvf40Q1srWQo DXHHSP+nAc3cZI93Z/3nIObsIOj0YsyzjAt9XIkeJxOSR1ChCL984V8BE3zYsjwCsAfg O4zPEK+MvBsOb7n5tB0uy5hpVWNtQmxhnZ+wSbEv1QRuHXZUxdGtf0t80LdvbQ4UGdV2 9/e20L9M2eSA7Y1hNpC+7ICFXO1uNWDNMXf3eFVlnAE7fkDGJPvyNvj2Sxrn7gh8IZKQ 56oZDai/SLi47Ts++qMVLvuqPm/uN8gFABs6IxLiYLReuFcR+KlMUu+WNptTCacH1mYa a7sw== X-Received: by 10.69.1.5 with SMTP id bc5mr7619951pbd.151.1444304981773; Thu, 08 Oct 2015 04:49:41 -0700 (PDT) Received: from arch-nb.localdomain ([211.106.186.1]) by smtp.gmail.com with ESMTPSA id qp5sm45081721pbc.43.2015.10.08.04.49.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Oct 2015 04:49:40 -0700 (PDT) From: Byongho Lee To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: cleanup iterating over prop_handlers array Date: Thu, 8 Oct 2015 20:49:34 +0900 Message-Id: <1444304974-30423-1-git-send-email-bhlee.kernel@gmail.com> X-Mailer: git-send-email 2.6.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch eliminates the last item of prop_handlers array which is used to check end of array and instead uses ARRAY_SIZE macro. Though this is a very tiny optimization, using ARRAY_SIZE macro is a good practice to iterate array. Signed-off-by: Byongho Lee Reviewed-by: David Sterba --- fs/btrfs/props.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c index dca137b04095..f9e60231f685 100644 --- a/fs/btrfs/props.c +++ b/fs/btrfs/props.c @@ -49,18 +49,16 @@ static struct prop_handler prop_handlers[] = { .extract = prop_compression_extract, .inheritable = 1 }, - { - .xattr_name = NULL - } }; void __init btrfs_props_init(void) { - struct prop_handler *p; + int i; hash_init(prop_handlers_ht); - for (p = &prop_handlers[0]; p->xattr_name; p++) { + for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) { + struct prop_handler *p = &prop_handlers[i]; u64 h = btrfs_name_hash(p->xattr_name, strlen(p->xattr_name)); hash_add(prop_handlers_ht, &p->node, h); @@ -301,15 +299,16 @@ static int inherit_props(struct btrfs_trans_handle *trans, struct inode *inode, struct inode *parent) { - const struct prop_handler *h; struct btrfs_root *root = BTRFS_I(inode)->root; int ret; + int i; if (!test_bit(BTRFS_INODE_HAS_PROPS, &BTRFS_I(parent)->runtime_flags)) return 0; - for (h = &prop_handlers[0]; h->xattr_name; h++) { + for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) { + const struct prop_handler *h = &prop_handlers[i]; const char *value; u64 num_bytes;