From: Jules Maselbas <jmaselbas@zdiv.net>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@zdiv.net>
Subject: [PATCH v2] commands: hwclock: rework argument handling
Date: Tue, 25 Mar 2025 12:52:26 +0100 [thread overview]
Message-ID: <20250325115226.1692-1-jmaselbas@zdiv.net> (raw)
In-Reply-To: <20250314213344.12335-1-jmaselbas@zdiv.net>
The rtc_name doesn't need to be an array, thus the argument doesn't
have to be copied, we can simply use a pointer on optarg.
Drop the array and the string copy.
Suggested-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
---
v2:
- remove strcpy call and use a pointer instead (Sascha)
commands/hwclock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/commands/hwclock.c b/commands/hwclock.c
index c594e070ac..b04b34cd7c 100644
--- a/commands/hwclock.c
+++ b/commands/hwclock.c
@@ -83,7 +83,7 @@ static int do_hwclock(int argc, char *argv[])
struct rtc_device *r;
struct rtc_time tm;
struct rtc_time stm;
- char rtc_name[16] = "rtc0";
+ const char *rtc_name = "rtc0";
char *env_name = NULL;
int opt;
int set = 0;
@@ -95,7 +95,7 @@ static int do_hwclock(int argc, char *argv[])
switch (opt) {
case 'f':
- strncpy(rtc_name, optarg, 16);
+ rtc_name = optarg;
break;
case 's':
memset(&stm, 0, sizeof(stm));
--
2.48.1
next prev parent reply other threads:[~2025-03-25 13:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 21:33 [PATCH] commands: hwclock: replace strncpy with strlcpy Jules Maselbas
2025-03-17 8:42 ` Sascha Hauer
2025-03-25 11:52 ` Jules Maselbas [this message]
2025-03-25 13:46 ` [PATCH v2] commands: hwclock: rework argument handling Sascha Hauer
2025-03-27 9:17 ` Sascha Hauer
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=20250325115226.1692-1-jmaselbas@zdiv.net \
--to=jmaselbas@zdiv.net \
--cc=barebox@lists.infradead.org \
/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