[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH v2] date: exit with failure when clock_settime fails
From:       Ladislav Michl <oss-lists () triops ! cz>
Date:       2023-12-01 13:53:08
Message-ID: ZWnlRN5tm1af4tMF () lenoch
[Download RAW message or body]

Gentle ping...

On Mon, Sep 18, 2023 at 11:11:48AM +0200, Ladislav Michl wrote:
> From: Ladislav Michl <ladis@linux-mips.org>
> 
> Coreutils date behaves this way since 1998-12-11 as done in their git commit
> a17cdb11731e ("(main): Arrange to exit unsuccessfully when stime fails.")
> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
>  CHANGES:
>  -v2: better compatibily with coreutils, add explaining commit message
> 
>  coreutils/date.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/coreutils/date.c b/coreutils/date.c
> index 3a89b6caf..09d5697dc 100644
> --- a/coreutils/date.c
> +++ b/coreutils/date.c
> @@ -166,12 +166,13 @@ int date_main(int argc UNUSED_PARAM, char **argv)
>  	struct tm tm_time;
>  	char buf_fmt_dt2str[64];
>  	unsigned opt;
> -	int isofmt = -1;
>  	char *date_str;
>  	char *fmt_dt2str;
>  	char *fmt_str2dt;
>  	char *filename;
>  	char *isofmt_arg = NULL;
> +	int ret = EXIT_SUCCESS;
> +	int isofmt = -1;
>  
>  	opt = getopt32long(argv, "^"
>  			"Rs:ud:r:"
> @@ -287,9 +288,12 @@ int date_main(int argc UNUSED_PARAM, char **argv)
>  		ts.tv_sec = validate_tm_time(date_str, &tm_time);
>  		ts.tv_nsec = 0;
>  
> -		/* if setting time, set it */
> +		/* if setting time, set the system clock to the specified date,
> +		 * then regardless of the success of that operation,
> +		 * format and print that date. */
>  		if ((opt & OPT_SET) && clock_settime(CLOCK_REALTIME, &ts) < 0) {
>  			bb_simple_perror_msg("can't set date");
> +			ret = EXIT_FAILURE;
>  		}
>  	}
>  
> @@ -383,5 +387,5 @@ int date_main(int argc UNUSED_PARAM, char **argv)
>  	}
>  	puts(date_buf);
>  
> -	return EXIT_SUCCESS;
> +	return ret;
>  }
> -- 
> 2.39.2
> 
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic