[git commit] date: maybe_set_utc only once

Denys Vlasenko vda.linux at googlemail.com
Thu Oct 5 10:53:25 UTC 2017


commit: https://git.busybox.net/busybox/commit/?id=6e2beb7dfee1a4542eca1a6e8c0f33486d9d5fb9
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

It's not clear at all why we do it twice. git archaeology did not help.

function                                             old     new   delta
date_main                                            836     839      +3
maybe_set_utc                                         16       -     -16

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/date.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/coreutils/date.c b/coreutils/date.c
index 5b15ce7..87dc3bb 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -36,8 +36,8 @@
 //config:# defaults to "no": stat's nanosecond field is a bit non-portable
 //config:config FEATURE_DATE_NANO
 //config:	bool "Support %[num]N nanosecond format specifier"
-//config:	default n
-//config:	depends on DATE  # syscall(__NR_clock_gettime)
+//config:	default n  # syscall(__NR_clock_gettime)
+//config:	depends on DATE
 //config:	select PLATFORM_LINUX
 //config:	help
 //config:	Support %[num]N format specifier. Adds ~250 bytes of code.
@@ -203,6 +203,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
 			IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt)
 	);
 	argv += optind;
+
 	maybe_set_utc(opt);
 
 	if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_TIMESPEC)) {
@@ -301,8 +302,6 @@ int date_main(int argc UNUSED_PARAM, char **argv)
 			tm_time.tm_isdst = -1;
 		ts.tv_sec = validate_tm_time(date_str, &tm_time);
 
-		maybe_set_utc(opt);
-
 		/* if setting time, set it */
 		if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) {
 			bb_perror_msg("can't set date");


More information about the busybox-cvs mailing list