From 27cbe0553c5d96240d9375e330e76b30bc156021 Mon Sep 17 00:00:00 2001 From: Pisit Sawangvonganan Date: Sat, 24 Aug 2024 01:37:19 +0700 Subject: [PATCH] shell: modules: date: omit `NULL` initialization of `endptr` As `strtol` guarantee to set `endptr`, the initial `NULL` can be omitted. Signed-off-by: Pisit Sawangvonganan --- subsys/shell/modules/date_service.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/subsys/shell/modules/date_service.c b/subsys/shell/modules/date_service.c index a7f4ec3e32b..4cfc7e75c0d 100644 --- a/subsys/shell/modules/date_service.c +++ b/subsys/shell/modules/date_service.c @@ -42,7 +42,6 @@ static int get_y_m_d(const struct shell *sh, struct tm *t, char *date_str) int day; char *endptr; - endptr = NULL; year = strtol(date_str, &endptr, 10); if ((endptr == date_str) || (*endptr != '-')) { return -EINVAL; @@ -50,7 +49,6 @@ static int get_y_m_d(const struct shell *sh, struct tm *t, char *date_str) date_str = endptr + 1; - endptr = NULL; month = strtol(date_str, &endptr, 10); if ((endptr == date_str) || (*endptr != '-')) { return -EINVAL; @@ -63,7 +61,6 @@ static int get_y_m_d(const struct shell *sh, struct tm *t, char *date_str) date_str = endptr + 1; - endptr = NULL; day = strtol(date_str, &endptr, 10); if ((endptr == date_str) || (*endptr != '\0')) { return -EINVAL; @@ -94,7 +91,6 @@ static int get_h_m_s(const struct shell *sh, struct tm *t, char *time_str) if (*time_str == ':') { time_str++; } else { - endptr = NULL; t->tm_hour = strtol(time_str, &endptr, 10); if (endptr == time_str) { return -EINVAL; @@ -113,7 +109,6 @@ static int get_h_m_s(const struct shell *sh, struct tm *t, char *time_str) if (*time_str == ':') { time_str++; } else { - endptr = NULL; t->tm_min = strtol(time_str, &endptr, 10); if (endptr == time_str) { return -EINVAL; @@ -129,7 +124,6 @@ static int get_h_m_s(const struct shell *sh, struct tm *t, char *time_str) } } - endptr = NULL; t->tm_sec = strtol(time_str, &endptr, 10); if ((endptr == time_str) || (*endptr != '\0')) { return -EINVAL;