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 <pisit@ndrsolution.com>
This commit is contained in:
parent
09f13a31e9
commit
27cbe0553c
1 changed files with 0 additions and 6 deletions
|
@ -42,7 +42,6 @@ static int get_y_m_d(const struct shell *sh, struct tm *t, char *date_str)
|
||||||
int day;
|
int day;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
|
|
||||||
endptr = NULL;
|
|
||||||
year = strtol(date_str, &endptr, 10);
|
year = strtol(date_str, &endptr, 10);
|
||||||
if ((endptr == date_str) || (*endptr != '-')) {
|
if ((endptr == date_str) || (*endptr != '-')) {
|
||||||
return -EINVAL;
|
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;
|
date_str = endptr + 1;
|
||||||
|
|
||||||
endptr = NULL;
|
|
||||||
month = strtol(date_str, &endptr, 10);
|
month = strtol(date_str, &endptr, 10);
|
||||||
if ((endptr == date_str) || (*endptr != '-')) {
|
if ((endptr == date_str) || (*endptr != '-')) {
|
||||||
return -EINVAL;
|
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;
|
date_str = endptr + 1;
|
||||||
|
|
||||||
endptr = NULL;
|
|
||||||
day = strtol(date_str, &endptr, 10);
|
day = strtol(date_str, &endptr, 10);
|
||||||
if ((endptr == date_str) || (*endptr != '\0')) {
|
if ((endptr == date_str) || (*endptr != '\0')) {
|
||||||
return -EINVAL;
|
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 == ':') {
|
if (*time_str == ':') {
|
||||||
time_str++;
|
time_str++;
|
||||||
} else {
|
} else {
|
||||||
endptr = NULL;
|
|
||||||
t->tm_hour = strtol(time_str, &endptr, 10);
|
t->tm_hour = strtol(time_str, &endptr, 10);
|
||||||
if (endptr == time_str) {
|
if (endptr == time_str) {
|
||||||
return -EINVAL;
|
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 == ':') {
|
if (*time_str == ':') {
|
||||||
time_str++;
|
time_str++;
|
||||||
} else {
|
} else {
|
||||||
endptr = NULL;
|
|
||||||
t->tm_min = strtol(time_str, &endptr, 10);
|
t->tm_min = strtol(time_str, &endptr, 10);
|
||||||
if (endptr == time_str) {
|
if (endptr == time_str) {
|
||||||
return -EINVAL;
|
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);
|
t->tm_sec = strtol(time_str, &endptr, 10);
|
||||||
if ((endptr == time_str) || (*endptr != '\0')) {
|
if ((endptr == time_str) || (*endptr != '\0')) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue