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 <[email protected]>
Signed-off-by: Jules Maselbas <[email protected]>
---
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


Reply via email to