All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: sandeen@sandeen.net, linux-xfs@vger.kernel.org
Cc: darrick.wong@oracle.com, jack@suse.com, jeffm@suse.com,
	okurz@suse.com, lpechacek@suse.com, jtulak@redhat.com,
	"Luis R. Rodriguez" <mcgrof@kernel.org>
Subject: [PATCH v5 3/4] mkfs: replace defaults source with an enum
Date: Thu,  7 Jun 2018 16:55:32 -0700	[thread overview]
Message-ID: <20180607235533.20391-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20180607235533.20391-1-mcgrof@kernel.org>

Using an enum will let us later just use a switch statement to print
out the source, this makes sources easier to document, update and
manage.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 mkfs/config.h   | 22 +++++++++++++++++++++-
 mkfs/xfs_mkfs.c |  5 +++--
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/mkfs/config.h b/mkfs/config.h
index e5ea968e2d65..a3c6c99c3064 100644
--- a/mkfs/config.h
+++ b/mkfs/config.h
@@ -54,6 +54,17 @@ struct sb_feat_args {
 	bool	nortalign;
 };
 
+/*
+ * File configuration type settings
+ *
+ * These are the different possibilities by which you can end up parsing
+ * default settings with. DEFAULTS_BUILTIN indicates there was no configuration
+ * file parsed and we are using the built-in defaults on this code.
+ */
+enum default_params_type {
+	DEFAULTS_BUILTIN = 0,
+};
+
 /*
  * Default filesystem features and configuration values
  *
@@ -63,7 +74,7 @@ struct sb_feat_args {
  * calculations.
  */
 struct mkfs_default_params {
-	char	*source;	/* where the defaults came from */
+	enum default_params_type type; /* where the defaults came from */
 
 	int	sectorsize;
 	int	blocksize;
@@ -75,4 +86,13 @@ struct mkfs_default_params {
 	struct fsxattr		fsx;
 };
 
+static inline const char *default_type_str(enum default_params_type type)
+{
+	switch (type) {
+	case DEFAULTS_BUILTIN:
+		return _("package built-in definitions");
+	}
+	return _("Unkown\n");
+}
+
 #endif /* _XFS_MKFS_CONFIG_H */
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 56e869d666be..2e344aa9dad1 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3722,7 +3722,7 @@ main(
 
 	/* build time defaults */
 	struct mkfs_default_params	dft = {
-		.source = _("package build definitions"),
+		.type = DEFAULTS_BUILTIN,
 		.sectorsize = XFS_MIN_SECTORSIZE,
 		.blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG,
 		.sb_feat = {
@@ -3762,7 +3762,8 @@ main(
 	 * implemented, emit a message to indicate where the defaults being
 	 * used came from.
 	 *
-	 * printf(_("Default configuration sourced from %s\n"), dft.source);
+	 * printf(_("Default configuration sourced from %s\n"),
+	 *	  default_type_str(dft.type));
 	 */
 
 	/* copy new defaults into CLI parsing structure */
-- 
2.16.3


  parent reply	other threads:[~2018-06-07 23:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 23:55 [PATCH v5 0/4] xfsprogs: add mkfs.xfs configuration file parsing support Luis R. Rodriguez
2018-06-07 23:55 ` [PATCH v5 1/4] mkfs: distinguish between struct sb_feat_args and struct cli_params Luis R. Rodriguez
2018-06-07 23:55 ` [PATCH v5 2/4] mkfs: move shared config structs and into their own headers Luis R. Rodriguez
2018-06-07 23:55 ` Luis R. Rodriguez [this message]
2018-06-07 23:55 ` [PATCH v5 4/4] mkfs.xfs: add configuration file parsing support using our own parser Luis R. Rodriguez
2018-06-08 22:18   ` Dave Chinner
2018-06-11 23:12   ` Eric Sandeen
2018-06-12  0:23     ` Luis R. Rodriguez
2018-06-12  1:02       ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180607235533.20391-4-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=darrick.wong@oracle.com \
    --cc=jack@suse.com \
    --cc=jeffm@suse.com \
    --cc=jtulak@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=lpechacek@suse.com \
    --cc=okurz@suse.com \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.