ext2fs: Consolidate duplicate min/max macros
PATCH 1/13 ext2fs: Consolidate duplicate min/max macros
Move duplicate min() and max() macro definitions from individual source files (alloc.c, fallocate.c, rehash.c) to the common ext2fs.h header.
Add include guards to prevent redefinition warnings when files define their own versions of these macros before including ext2fs.h.
Signed-off-by Artem Blagodarenko <[email protected]>
Reviewed-by Andreas Dilger <[email protected]>
--- lib/ext2fs/alloc.c | 2 -- lib/ext2fs/ext2fs.h | 9 +++++++++ lib/ext2fs/fallocate.c | 1 - misc/e4defrag.c | 1 - 4 files changed, 9 insertions(+), 4 deletions(-)
lib/ext2fs/alloc.c +0 -2
@@ -26,8 +26,6 @@#include "ext2_fs.h" #include "ext2fs.h" -#define min (a, b) ((a) < (b) ? (a) : (b)) -#undef DEBUG#ifdef DEBUG
lib/ext2fs/ext2fs.h +9 -0
@@ -134,6 +134,15 @@ typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_block_bitmap;#define EXT2_FIRST_INODE (s) EXT2_FIRST_INO(s) +/* +* Utility macros +*/ +#ifndef min +#define min (a, b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +#define max (a, b) ((a) > (b) ? (a) : (b)) +#endif /* * Badblocks list definitions
lib/ext2fs/fallocate.c +0 -1
@@ -17,7 +17,6 @@#include "ext2_fs.h" #include "ext2fs.h" -#define min (a, b) ((a) < (b) ? (a) : (b))#undef DEBUG
misc/e4defrag.c +0 -1
@@ -59,7 +59,6 @@ fprintf(stderr, "\t%s\n", (msg))#define STATISTIC_ERR_MSG_WITH_ERRNO (msg) \ fprintf(stderr, "\t%s:%s\n", (msg), strerror(errno)) -#define min (x, y) (((x) > (y)) ? (y) : (x))#define CALC_SCORE (ratio) \ ((ratio) > 10 ? (80 + 20 * (ratio) / 100) : (8 * (ratio)))/* Wrap up the free function */
Signature · 1 line
2.43.7