[LTP] [PATCH 3/6] Remove unnecessary header includes

Cyril Hrubis chrubis@suse.cz
Tue Jun 21 12:24:42 CEST 2022


Hi!
> ---
>  testcases/kernel/syscalls/utime/utime03.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/utime/utime03.c b/testcases/kernel/syscalls/utime/utime03.c
> index 2358fd70b..0c64518d2 100644
> --- a/testcases/kernel/syscalls/utime/utime03.c
> +++ b/testcases/kernel/syscalls/utime/utime03.c
> @@ -18,11 +18,8 @@
>   * - The user ID of the process has write access to the file.
>   */
>  
> -#include <sys/types.h>
>  #include <pwd.h>
>  #include <utime.h>
> -#include <sys/stat.h>
> -#include <time.h>
>  
>  #include "tst_test.h"
>  #include "tst_uid.h"
> @@ -60,7 +57,7 @@ static void run(void)
>  	struct stat statbuf;
>  	time_t mintime, maxtime;
>  
> -	utbuf.modtime = time(0) - 5;
> +	utbuf.modtime = tst_get_fs_timestamp() - 5;

This change is not explained in the patch description moreover ideally
patches should do one logical change so if we are going to accept these
changes they should be split into a patch that removes includes and
patch that replaces the time(0).

Although usage of time(0) is not really critical here, the difference
between the time(0) and tst_get_fs_timestamp() is that they may be out
of sync by 1 second as they are not incremenented at the exactly same
time. Hence it does not matter if we set time 5 +-1 seconds in the past
since the result is 100% different from current time.

>  	utbuf.actime = utbuf.modtime + 1;
>  	TST_EXP_PASS_SILENT(utime(TEMP_FILE, &utbuf));
>  	SAFE_STAT(TEMP_FILE, &statbuf);
> -- 
> 2.36.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list