Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests/powerpc: Rm the unnecessary remove function.
@ 2024-09-27  4:31 zhangjiao2
  2024-09-27 15:45 ` Ritesh Harjani
  0 siblings, 1 reply; 2+ messages in thread
From: zhangjiao2 @ 2024-09-27  4:31 UTC (permalink / raw)
  To: shuah; +Cc: mpe, linuxppc-dev, linux-kselftest, linux-kernel, zhang jiao

From: zhang jiao <zhangjiao2@cmss.chinamobile.com>

Path is not initialized before use,
remove the unnecessary remove function.

Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
 tools/testing/selftests/powerpc/mm/tlbie_test.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/mm/tlbie_test.c b/tools/testing/selftests/powerpc/mm/tlbie_test.c
index 48344a74b212..fd1456d16a7d 100644
--- a/tools/testing/selftests/powerpc/mm/tlbie_test.c
+++ b/tools/testing/selftests/powerpc/mm/tlbie_test.c
@@ -314,7 +314,6 @@ static inline void end_verification_log(unsigned int tid, unsigned nr_anamolies)
 	fclose(f);
 
 	if (nr_anamolies == 0) {
-		remove(path);
 		return;
 	}
 
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests/powerpc: Rm the unnecessary remove function.
  2024-09-27  4:31 [PATCH] selftests/powerpc: Rm the unnecessary remove function zhangjiao2
@ 2024-09-27 15:45 ` Ritesh Harjani
  0 siblings, 0 replies; 2+ messages in thread
From: Ritesh Harjani @ 2024-09-27 15:45 UTC (permalink / raw)
  To: zhangjiao2, shuah
  Cc: mpe, linuxppc-dev, linux-kselftest, linux-kernel, zhang jiao

zhangjiao2 <zhangjiao2@cmss.chinamobile.com> writes:

> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
>
> Path is not initialized before use,
> remove the unnecessary remove function.
>
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> ---
>  tools/testing/selftests/powerpc/mm/tlbie_test.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/tools/testing/selftests/powerpc/mm/tlbie_test.c b/tools/testing/selftests/powerpc/mm/tlbie_test.c
> index 48344a74b212..fd1456d16a7d 100644
> --- a/tools/testing/selftests/powerpc/mm/tlbie_test.c
> +++ b/tools/testing/selftests/powerpc/mm/tlbie_test.c
> @@ -314,7 +314,6 @@ static inline void end_verification_log(unsigned int tid, unsigned nr_anamolies)
>  	fclose(f);
>  
>  	if (nr_anamolies == 0) {
> -		remove(path);
>  		return;
>  	}

Nice catch. Indeed the path is uninitialized here. 

However, I believe the above "if" block should come after initializing
the path. The idea is if there were no anamolies noted, then we can
simply remove the log file and return.

Something like below. Thoughts?

diff --git a/tools/testing/selftests/powerpc/mm/tlbie_test.c b/tools/testing/selftests/powerpc/mm/tlbie_test.c
index 48344a74b212..35f0098399cc 100644
--- a/tools/testing/selftests/powerpc/mm/tlbie_test.c
+++ b/tools/testing/selftests/powerpc/mm/tlbie_test.c
@@ -313,16 +313,16 @@ static inline void end_verification_log(unsigned int tid, unsigned nr_anamolies)

        fclose(f);

-       if (nr_anamolies == 0) {
-               remove(path);
-               return;
-       }
-
        sprintf(logfile, logfilename, tid);
        strcpy(path, logdir);
        strcat(path, separator);
        strcat(path, logfile);

+       if (nr_anamolies == 0) {
+               remove(path);
+               return;
+       }
+
        printf("Thread %02d chunk has %d corrupted words. For details check %s\n",
                tid, nr_anamolies, path);
 }


-ritesh

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-27 15:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-27  4:31 [PATCH] selftests/powerpc: Rm the unnecessary remove function zhangjiao2
2024-09-27 15:45 ` Ritesh Harjani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox