[05/12] fsx: use an enum to define the operation commands
diff mbox series

Message ID 154290953980.1218.7605730679708903723.stgit@magnolia
State New
Headers show
Series
  • xfstests: add copy/dedupe/clone to fsx/fsstress
Related show

Commit Message

Darrick J. Wong Nov. 22, 2018, 5:58 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Use an enum to define operation codes and the boundaries between
operation classes so that we can add new commands without having to
change a bunch of unrelated #defines.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 ltp/fsx.c |   40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

Comments

Allison Henderson Nov. 24, 2018, 6:23 p.m. UTC | #1
Looks ok to me

Reviewed-By: Allison Henderson <allison.henderson@oracle.com>

On 11/22/18 10:58 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Use an enum to define operation codes and the boundaries between
> operation classes so that we can add new commands without having to
> change a bunch of unrelated #defines.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>   ltp/fsx.c |   40 +++++++++++++++++++++-------------------
>   1 file changed, 21 insertions(+), 19 deletions(-)
> 
> 
> diff --git a/ltp/fsx.c b/ltp/fsx.c
> index 7fb8b3ab..dabad302 100644
> --- a/ltp/fsx.c
> +++ b/ltp/fsx.c
> @@ -88,25 +88,27 @@ int			logcount = 0;	/* total ops */
>    * mode being run.
>    */
>   
> -/* common operations */
> -#define	OP_READ		0
> -#define OP_WRITE	1
> -#define OP_MAPREAD	2
> -#define OP_MAPWRITE	3
> -#define OP_MAX_LITE	4
> -
> -/* !lite operations */
> -#define OP_TRUNCATE		4
> -#define OP_FALLOCATE		5
> -#define OP_PUNCH_HOLE		6
> -#define OP_ZERO_RANGE		7
> -#define OP_COLLAPSE_RANGE	8
> -#define OP_INSERT_RANGE	9
> -#define OP_MAX_FULL		10
> -
> -/* integrity operations */
> -#define OP_FSYNC		10
> -#define OP_MAX_INTEGRITY	11
> +enum {
> +	/* common operations */
> +	OP_READ = 0,
> +	OP_WRITE,
> +	OP_MAPREAD,
> +	OP_MAPWRITE,
> +	OP_MAX_LITE,
> +
> +	/* !lite operations */
> +	OP_TRUNCATE = OP_MAX_LITE,
> +	OP_FALLOCATE,
> +	OP_PUNCH_HOLE,
> +	OP_ZERO_RANGE,
> +	OP_COLLAPSE_RANGE,
> +	OP_INSERT_RANGE,
> +	OP_MAX_FULL,
> +
> +	/* integrity operations */
> +	OP_FSYNC = OP_MAX_FULL,
> +	OP_MAX_INTEGRITY,
> +};
>   
>   #undef PAGE_SIZE
>   #define PAGE_SIZE       getpagesize()
>

Patch
diff mbox series

diff --git a/ltp/fsx.c b/ltp/fsx.c
index 7fb8b3ab..dabad302 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -88,25 +88,27 @@  int			logcount = 0;	/* total ops */
  * mode being run.
  */
 
-/* common operations */
-#define	OP_READ		0
-#define OP_WRITE	1
-#define OP_MAPREAD	2
-#define OP_MAPWRITE	3
-#define OP_MAX_LITE	4
-
-/* !lite operations */
-#define OP_TRUNCATE		4
-#define OP_FALLOCATE		5
-#define OP_PUNCH_HOLE		6
-#define OP_ZERO_RANGE		7
-#define OP_COLLAPSE_RANGE	8
-#define OP_INSERT_RANGE	9
-#define OP_MAX_FULL		10
-
-/* integrity operations */
-#define OP_FSYNC		10
-#define OP_MAX_INTEGRITY	11
+enum {
+	/* common operations */
+	OP_READ = 0,
+	OP_WRITE,
+	OP_MAPREAD,
+	OP_MAPWRITE,
+	OP_MAX_LITE,
+
+	/* !lite operations */
+	OP_TRUNCATE = OP_MAX_LITE,
+	OP_FALLOCATE,
+	OP_PUNCH_HOLE,
+	OP_ZERO_RANGE,
+	OP_COLLAPSE_RANGE,
+	OP_INSERT_RANGE,
+	OP_MAX_FULL,
+
+	/* integrity operations */
+	OP_FSYNC = OP_MAX_FULL,
+	OP_MAX_INTEGRITY,
+};
 
 #undef PAGE_SIZE
 #define PAGE_SIZE       getpagesize()