From patchwork Mon May 11 08:08:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 6373861 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 1CD9F9F399 for ; Mon, 11 May 2015 08:09:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 447142035E for ; Mon, 11 May 2015 08:09:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DBCE2037F for ; Mon, 11 May 2015 08:09:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752658AbbEKIJE (ORCPT ); Mon, 11 May 2015 04:09:04 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:64834 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752199AbbEKIJB (ORCPT ); Mon, 11 May 2015 04:09:01 -0400 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="91967343" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 May 2015 16:05:02 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t4B87aLR028746 for ; Mon, 11 May 2015 16:07:37 +0800 Received: from localhost.localdomain (10.167.226.33) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 11 May 2015 16:09:00 +0800 From: Qu Wenruo To: Subject: [PATCH v2 02/13] btrfs-progs: Use unified function to implement print_readable_*_flag() function. Date: Mon, 11 May 2015 16:08:43 +0800 Message-ID: <1431331734-11714-3-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.4.0 In-Reply-To: <1431331734-11714-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1431331734-11714-1-git-send-email-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.33] 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Now add a new unified __print_readable_flag() function to implement print_readable_incompat_flag(). This makes later extension for human readable flags easier. Signed-off-by: Qu Wenruo --- v2: Newly introduced. --- btrfs-show-super.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/btrfs-show-super.c b/btrfs-show-super.c index 1c7a086..430ddfe 100644 --- a/btrfs-show-super.c +++ b/btrfs-show-super.c @@ -305,7 +305,8 @@ struct readable_flag_entry incompat_flags_array[] = { static const int incompat_flags_num = sizeof(incompat_flags_array) / sizeof(struct readable_flag_entry); -static void print_readable_incompat_flag(u64 flag) +static void __print_readable_flag(u64 flag, struct readable_flag_entry *array, + int array_size, u64 supported_flags) { int i; int first = 1; @@ -313,9 +314,10 @@ static void print_readable_incompat_flag(u64 flag) if (!flag) return; + printf("\t\t\t( "); - for (i = 0; i < incompat_flags_num; i++) { - entry = incompat_flags_array + i; + for (i = 0; i < array_size; i++) { + entry = array + i; if (flag & entry->bit) { if (first) printf("%s ", entry->output); @@ -324,7 +326,7 @@ static void print_readable_incompat_flag(u64 flag) first = 0; } } - flag &= ~BTRFS_FEATURE_INCOMPAT_SUPP; + flag &= ~supported_flags; if (flag) { if (first) printf("unknown flag: 0x%llx ", flag); @@ -334,6 +336,13 @@ static void print_readable_incompat_flag(u64 flag) printf(")\n"); } +static void print_readable_incompat_flag(u64 flag) +{ + return __print_readable_flag(flag, incompat_flags_array, + incompat_flags_num, + BTRFS_FEATURE_INCOMPAT_SUPP); +} + static void dump_superblock(struct btrfs_super_block *sb, int full) { int i;