From patchwork Sun Apr 23 18:54:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Tulak X-Patchwork-Id: 9695235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 56D62601E9 for ; Sun, 23 Apr 2017 18:55:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AABD26490 for ; Sun, 23 Apr 2017 18:55:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3632B269E2; Sun, 23 Apr 2017 18:55:17 +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=-6.9 required=2.0 tests=BAYES_00,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 E634126490 for ; Sun, 23 Apr 2017 18:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163236AbdDWSzP (ORCPT ); Sun, 23 Apr 2017 14:55:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58648 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163244AbdDWSzP (ORCPT ); Sun, 23 Apr 2017 14:55:15 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A317166CBA for ; Sun, 23 Apr 2017 18:55:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A317166CBA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jtulak@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A317166CBA Received: from honza-mbp.redhat.com (ovpn-204-62.brq.redhat.com [10.40.204.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1F681F8; Sun, 23 Apr 2017 18:55:13 +0000 (UTC) From: Jan Tulak To: linux-xfs@vger.kernel.org Cc: Jan Tulak Subject: [PATCH 06/12] mkfs: create get/set functions for opts table Date: Sun, 23 Apr 2017 20:54:57 +0200 Message-Id: <20170423185503.31415-7-jtulak@redhat.com> In-Reply-To: <20170423185503.31415-1-jtulak@redhat.com> References: <20170423185503.31415-1-jtulak@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 23 Apr 2017 18:55:14 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add functions that can be used to get/set values to opts table. Signed-off-by: Jan Tulak --- mkfs/xfs_mkfs.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index c2ffd91..4caf93c 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -786,6 +786,38 @@ get_conf_raw(int opt, int subopt) return opts[opt].subopt_params[subopt].raw_input; } +static uint64_t getnum(const char *str, struct opt_params *opts, int index); + +/* + * Get and set values to the opts table. + */ +static inline uint64_t +get_conf_val(int opt, int subopt) +{ + return opts[opt].subopt_params[subopt].value; +} + +static void +set_conf_val(int opt, int subopt, uint64_t val) +{ + struct subopt_param *sp = &opts[opt].subopt_params[subopt]; + + sp->value = val; +} + +/* + * A wrapper for getnum and set_conf_val. + */ +static inline uint64_t +parse_conf_val(int opt, int subopt, char *value) +{ + uint64_t num = getnum(value, &opts[opt], subopt); + + set_conf_val(opt, subopt, num); + return num; +} + + /* * Convert lsu to lsunit for 512 bytes blocks and check validity of the values. */