[LTP] [PATCH 1/1] tst_test: Fix test regression on -i

Petr Vorel pvorel@suse.cz
Mon Sep 21 10:45:38 CEST 2026


50745a2918 correctly changed iterations from int to unsigned int.
But UINT_MAX SAFE_STRTOUL() needs to be used, otherwise simple -i2
fails due UINT_MAX overflowed:

    tst_test.c:836: TBROK: strtol(2): 2 is out of range 0 - -1

Fixes: 50745a2918 ("lib: tst_test: Move the iterations to struct tst_test")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 2b38d0063d..ed3d26cad0 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -833,7 +833,7 @@ static void parse_opts(int argc, char *argv[])
 			print_test_tags();
 			exit(0);
 		case 'i':
-			tst_test->iterations = SAFE_STRTOL(optarg, 0, UINT_MAX);
+			tst_test->iterations = SAFE_STRTOUL(optarg, 0, UINT_MAX);
 		break;
 		case 'I':
 			if (tst_test->runtime > 0)
-- 
2.55.0



More information about the ltp mailing list