diff mbox series

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

Message ID 20231108074935.1409644-2-pvorel@suse.cz
State Accepted
Headers show
Series [1/2] link05: Return on link() failure | expand

Commit Message

Petr Vorel Nov. 8, 2023, 7:49 a.m. UTC
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(-)

Comments

Andrea Cervesato Feb. 8, 2024, 1:25 p.m. UTC | #1
Hi!

LGTM

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

Regards,
Andrea

On 11/8/23 08:49, Petr Vorel wrote:
> 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:
Petr Vorel Feb. 19, 2024, 9:29 p.m. UTC | #2
Hi Andrea,

> Hi!

> LGTM

> Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

Thanks for your review, merged.

Could you please use "reply to all" when posting your review?
That way you reply directly to the autor (and possibly other people in the
thread), which speedups the process (I guess I'm not the only one who expects to
get comments directly, I find this just by change). Thank you!

Kind regards,
Petr

> Regards,
> Andrea
diff mbox series

Patch

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: