Skip to contentSkip to conversation

cmd: date: Do not overwrite arguments

PATCH In review Roman Kapl 2 participants 2 messages Feb 8, 2019 – Feb 20, 2019

lore
Share & tools
lore

Roman Kapl

author
#0 lore raw

PATCH 1/1 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.

---
 cmd/date.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
cmd/date.c +4 -4
index 1115b6c8d6..7fa950a902 100644
@@ -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);
Signature · 1 line
2.20.1.390.gb5101f9297
#1 lore raw
Quoted 4 lines · Roman Kapl

Arguments are const and belong to the caller. Calling date in a hush loop will yield different results from the second invocation.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190219/ef85f486/attachment.sig>