From: Roman Kapl Date: Fri, 8 Feb 2019 09:01:02 +0000 (+0100) Subject: cmd: date: Do not overwrite arguments X-Git-Tag: v2019.04-rc3~15^2~20 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=44ac80e7e90ff1c6630b64b3babe03cc6bdef46a;p=oweals%2Fu-boot.git cmd: date: Do not overwrite arguments Arguments are const and belong to the caller. Calling date in a hush loop will yield different results from the second invocation. Signed-off-by: Roman Kapl --- diff --git a/cmd/date.c b/cmd/date.c index 1115b6c8d6..7fa950a902 100644 --- a/cmd/date.c +++ b/cmd/date.c @@ -159,18 +159,18 @@ int mk_date (const char *datestr, struct rtc_time *tmp) int len, val; char *ptr; - ptr = strchr (datestr,'.'); - len = strlen (datestr); + ptr = strchr(datestr, '.'); + len = strlen(datestr); /* Set seconds */ if (ptr) { int sec; - *ptr++ = '\0'; + ptr++; if ((len - (ptr - datestr)) != 2) return (-1); - len = strlen (datestr); + len -= 3; if (cnvrt2 (ptr, &sec)) return (-1);