* [PATCH] xfs_repair: fix getsubopt name definitions to use enums
@ 2018-04-10 5:20 Darrick J. Wong
2018-04-12 15:22 ` Eric Sandeen
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2018-04-10 5:20 UTC (permalink / raw)
To: xfs, Eric Sandeen
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,
};
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] xfs_repair: fix getsubopt name definitions to use enums
2018-04-10 5:20 [PATCH] xfs_repair: fix getsubopt name definitions to use enums Darrick J. Wong
@ 2018-04-12 15:22 ` Eric Sandeen
0 siblings, 0 replies; 2+ messages in thread
From: Eric Sandeen @ 2018-04-12 15:22 UTC (permalink / raw)
To: Darrick J. Wong, xfs
On 4/10/18 12:20 AM, Darrick J. Wong wrote:
> 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>
Ugh, sorry for not catching that myself, thanks.
Fixes-commit: 42fa89bc1b ("xfs_repair: remove pre_65_beta option")
Reviewed-by: Eric Sandeen <sandeen@redhat.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,
> };
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-12 15:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-10 5:20 [PATCH] xfs_repair: fix getsubopt name definitions to use enums Darrick J. Wong
2018-04-12 15:22 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).