[LTP] [PATCH v5 3/5] mmapstress01: define fsize bounds by file offset bits

Edward Liaw edliaw@google.com
Wed Oct 12 16:48:21 CEST 2022


Signed-off-by: Edward Liaw <edliaw@google.com>
---
 .../kernel/mem/mmapstress/mmapstress01.c      | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index dee73de5e..ea818ffcd 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -36,6 +36,13 @@
 #include <float.h>
 #include "tst_test.h"
 
+#if _FILE_OFFSET_BITS == 64
+# define FSIZE_MIN LONG_MIN
+# define FSIZE_MAX LONG_MAX
+#else
+# define FSIZE_MIN INT_MIN
+# define FSIZE_MAX INT_MAX
+#endif
 #define MAXLOOPS	500	/* max pages for map children to write */
 #define TEST_FILE	"mmapstress01.out"
 
@@ -83,18 +90,10 @@ static void setup(void)
 {
 	int pagesize = sysconf(_SC_PAGE_SIZE);
 
-#if _FILE_OFFSET_BITS == 64
-	if (tst_parse_filesize(opt_filesize, &filesize, 0, LONG_MAX))
-#else
-	if (tst_parse_filesize(opt_filesize, &filesize, 0, INT_MAX))
-#endif
+	if (tst_parse_filesize(opt_filesize, &filesize, 0, FSIZE_MAX))
 		tst_brk(TBROK, "invalid initial filesize '%s'", opt_filesize);
 
-#if _FILE_OFFSET_BITS == 64
-	if (tst_parse_filesize(opt_sparseoffset, &sparseoffset, LONG_MIN, LONG_MAX))
-#else
-	if (tst_parse_filesize(opt_sparseoffset, &sparseoffset, INT_MIN, INT_MAX))
-#endif
+	if (tst_parse_filesize(opt_sparseoffset, &sparseoffset, FSIZE_MIN, FSIZE_MAX))
 		tst_brk(TBROK, "invalid sparse offset '%s'", opt_sparseoffset);
 	if (sparseoffset % pagesize != 0)
 		tst_brk(TBROK, "sparseoffset must be pagesize multiple");
-- 
2.38.0.rc1.362.ged0d419d3c-goog



More information about the ltp mailing list