From: Roman Kapl <rka@sysgo.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] cmd: date: Do not overwrite arguments
Date: Fri, 8 Feb 2019 10:01:02 +0100 [thread overview]
Message-ID: <20190208090102.14269-1-rka@sysgo.com> (raw)
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
next reply other threads:[~2019-02-08 9:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 9:01 Roman Kapl [this message]
2019-02-20 1:57 ` [U-Boot] cmd: date: Do not overwrite arguments Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190208090102.14269-1-rka@sysgo.com \
--to=rka@sysgo.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox