[LTP] [PATCH 1/1] nfs01_open_files: Fix pattern for deleted files

Cyril Hrubis chrubis@suse.cz
Fri Mar 11 13:43:47 CET 2022


Hi!
> Reported-by: Neil Brown <neilb@suse.de>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/network/nfs/nfs_stress/nfs01_open_files.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/network/nfs/nfs_stress/nfs01_open_files.c b/testcases/network/nfs/nfs_stress/nfs01_open_files.c
> index 9342f11ba9..c5627058dc 100644
> --- a/testcases/network/nfs/nfs_stress/nfs01_open_files.c
> +++ b/testcases/network/nfs/nfs_stress/nfs01_open_files.c
> @@ -10,7 +10,8 @@
>  #include <sys/stat.h>
>  #include <unistd.h>
>  
> -#define TEMPLATE "ltpXXXXXX"
> +#define TEMPLATE_PREFIX "ltp"
> +#define TEMPLATE TEMPLATE_PREFIX "XXXXXX"
>  
>  int write_something(int);
>  void delete_files(void);
> @@ -101,7 +102,7 @@ void delete_files(void)
>  
>  	dirp = opendir(".");
>  	for (entp = readdir(dirp); entp; entp = readdir(dirp))
> -		if (!strncmp(entp->d_name, "apt", 3)) {
> +		if (!strncmp(entp->d_name, TEMPLATE_PREFIX, 3)) {

Maybe we should also do:

#define TEMPLATE_PREFIX_LEN (sizeof(TEMPLATE_PREFIX) - 1)

And use TEMPLATE_PREFIX_LEN instead of the hardcoded 3


Otherwise it looks obviously correct:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list