[LTP] [PATCH 2/2] link05: Use constant for number of links

Petr Vorel pvorel@suse.cz
Wed Nov 8 08:49:35 CET 2023


No need to create variable, when number of links is not changed.

Fixes: d908fd870 ("link/link05: Convert to new API")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/link/link05.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/link/link05.c b/testcases/kernel/syscalls/link/link05.c
index 1d708c6f6..a188da18d 100644
--- a/testcases/kernel/syscalls/link/link05.c
+++ b/testcases/kernel/syscalls/link/link05.c
@@ -15,18 +15,17 @@
 #include "tst_test.h"
 
 #define BASENAME	"lkfile"
+#define NLINKS	1000
 
 static char fname[255];
 
-static int nlinks = 1000;
-
 static void verify_link(void)
 {
 	int cnt = 0, created;
 	char lname[1024];
 	struct stat fbuf, lbuf;
 
-	for (created = 1; created < nlinks; created++) {
+	for (created = 1; created < NLINKS; created++) {
 		sprintf(lname, "%s_%d", fname, created);
 		TST_EXP_PASS_SILENT(link(fname, lname), "%d: link(%s, %s)", created,
 							fname, lname);
@@ -36,7 +35,7 @@ static void verify_link(void)
 
 	SAFE_STAT(fname, &fbuf);
 
-	for (cnt = 1; cnt < nlinks; cnt++) {
+	for (cnt = 1; cnt < NLINKS; cnt++) {
 		sprintf(lname, "%s_%d", fname, cnt);
 
 		SAFE_STAT(lname, &lbuf);
@@ -45,16 +44,16 @@ static void verify_link(void)
 
 			tst_res(TFAIL,
 				 "link(%s, %s[1-%d]) ret %ld for %d files, stat values do not match %d %d",
-				 fname, fname, nlinks, TST_RET, nlinks,
+				 fname, fname, NLINKS, TST_RET, NLINKS,
 				 (int)fbuf.st_nlink, (int)lbuf.st_nlink);
 			break;
 		}
 	}
 
-	if (cnt == nlinks) {
+	if (cnt == NLINKS) {
 		tst_res(TPASS,
 			 "link(%s, %s[1-%d]) ret %ld for %d files, stat linkcounts match %d",
-			 fname, fname, nlinks, TST_RET, nlinks, (int)fbuf.st_nlink);
+			 fname, fname, NLINKS, TST_RET, NLINKS, (int)fbuf.st_nlink);
 	}
 
 cleanup:
-- 
2.42.0



More information about the ltp mailing list