All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd: date: Do not overwrite arguments
@ 2019-02-08  9:01 Roman Kapl
  2019-02-20  1:57 ` [U-Boot] " Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Roman Kapl @ 2019-02-08  9:01 UTC (permalink / raw)
  To: u-boot

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 <rka@sysgo.com>
---
 cmd/date.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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);
-- 
2.20.1.390.gb5101f9297

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-20  1:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08  9:01 [U-Boot] [PATCH] cmd: date: Do not overwrite arguments Roman Kapl
2019-02-20  1:57 ` [U-Boot] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.