From: Darrick J. Wong Date: Thu, 12 Apr 2018 15:34:11 +0000 (-0500) Subject: xfs_repair: fix getsubopt name definitions to use enums X-Git-Tag: v4.16.0-rc1~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98884b660babfb3bb34587c97f811f856e75d462;p=thirdparty%2Fxfsprogs-dev.git xfs_repair: fix getsubopt name definitions to use enums 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 Fixes: 42fa89bc1b ("xfs_repair: remove pre_65_beta option") Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index b2a243204..ff6a73842 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, };