All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: xfs <linux-xfs@vger.kernel.org>, Eric Sandeen <sandeen@redhat.com>
Subject: [PATCH] xfs_repair: fix getsubopt name definitions to use enums
Date: Mon, 9 Apr 2018 22:20:53 -0700	[thread overview]
Message-ID: <20180410052053.GS7500@magnolia> (raw)

From: Darrick J. Wong <darrick.wong@oracle.com>

Convert the getsubopt usage in xfs_repair to use enums and explicitly
initialized array elements, similar to mkfs.  This also fixes the hole
in the o_opts table caused by 42fa89bc1b8dc8 ("xfs_repair: remove
pre_65_beta option") that causes segfaults in xfs/179 and xfs/202.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 repair/xfs_repair.c |   40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index b2a2432..ff6a738 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -46,29 +46,37 @@
 /*
  * -o: user-supplied override options
  */
+enum o_opt_nums {
+	ASSUME_XFS = 0,
+	IHASH_SIZE,
+	BHASH_SIZE,
+	AG_STRIDE,
+	FORCE_GEO,
+	PHASE2_THREADS,
+	O_MAX_OPTS,
+};
+
 static char *o_opts[] = {
-#define ASSUME_XFS	0
-	"assume_xfs",
-#define	IHASH_SIZE	2
-	"ihash",
-#define	BHASH_SIZE	3
-	"bhash",
-#define	AG_STRIDE	4
-	"ag_stride",
-#define FORCE_GEO	5
-	"force_geometry",
-#define PHASE2_THREADS	6
-	"phase2_threads",
-	NULL
+	[ASSUME_XFS]		= "assume_xfs",
+	[IHASH_SIZE]		= "ihash",
+	[BHASH_SIZE]		= "bhash",
+	[AG_STRIDE]		= "ag_stride",
+	[FORCE_GEO]		= "force_geometry",
+	[PHASE2_THREADS]	= "phase2_threads",
+	[O_MAX_OPTS]		= NULL,
 };
 
 /*
  * -c: conversion options
  */
+enum c_opt_nums {
+	CONVERT_LAZY_COUNT = 0,
+	C_MAX_OPTS,
+};
+
 static char *c_opts[] = {
-#define CONVERT_LAZY_COUNT	0
-	"lazycount",
-	NULL
+	[CONVERT_LAZY_COUNT]	= "lazycount",
+	[C_MAX_OPTS]		= NULL,
 };
 
 

             reply	other threads:[~2018-04-10  5:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10  5:20 Darrick J. Wong [this message]
2018-04-12 15:22 ` [PATCH] xfs_repair: fix getsubopt name definitions to use enums Eric Sandeen

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=20180410052053.GS7500@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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.