Re: [PATCH v2] date: exit with failure when clock_settime fails
Hi Dominique, On Mon, May 06, 2024 at 03:06:22PM +0900, Dominique Martinet wrote: > Ladislav Michl wrote on Mon, May 06, 2024 at 07:48:53AM +0200: > > Yet another gentle ping. It will be sent approximately once a year until > > some reaction seen. > > Oh, I had just noticed the same thing a bit ago and considered > changing the bb_simple_perror_msg to the _and_die variant, but stopped > as that wouldn't print the date anymore (as date should) > > Either this or die variant would be appreciated, I didn't appreciate > some "set time" script not returning an error while not setting the date > either. Thanks for review. Above is the exact same reason why this patch was created. > code looks good to me: > Reviewed-by: Dominique Martinet > > On commit message it might help to add a bloatcheck (remove patch, make > baseline, re-apply patch, make bloatcheck) Ok, for completeness: function old new delta date_main835 842 +7 -- (add/remove: 0/0 grow/shrink: 1/0 up/down: 7/0) Total: 7 bytes textdata bss dec hex filename 652657 103391744 664740 a24a4 busybox_old 652664 103391744 664747 a24ab busybox_unstripped Lets wait a little for input from maintainers. If required I'll resend as v3. Thanks ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH v2] date: exit with failure when clock_settime fails
Ladislav Michl wrote on Mon, May 06, 2024 at 07:48:53AM +0200: > Yet another gentle ping. It will be sent approximately once a year until > some reaction seen. Oh, I had just noticed the same thing a bit ago and considered changing the bb_simple_perror_msg to the _and_die variant, but stopped as that wouldn't print the date anymore (as date should) Either this or die variant would be appreciated, I didn't appreciate some "set time" script not returning an error while not setting the date either. code looks good to me: Reviewed-by: Dominique Martinet On commit message it might help to add a bloatcheck (remove patch, make baseline, re-apply patch, make bloatcheck) Thanks, -- Dominique ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH v2] date: exit with failure when clock_settime fails
Yet another gentle ping. It will be sent approximately once a year until some reaction seen. On Fri, Dec 01, 2023 at 02:53:08PM +0100, Ladislav Michl wrote: > Gentle ping... > > On Mon, Sep 18, 2023 at 11:11:48AM +0200, Ladislav Michl wrote: > > From: Ladislav Michl > > > > 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 > > --- > > 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, _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, ) < 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 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH v2] date: exit with failure when clock_settime fails
Gentle ping... On Mon, Sep 18, 2023 at 11:11:48AM +0200, Ladislav Michl wrote: > From: Ladislav Michl > > 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 > --- > 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, _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, ) < 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