diff options
| author | Mingjie Shen <[email protected]> | 2023-06-13 18:10:03 -0400 |
|---|---|---|
| committer | Man, Jianting (Meco) <[email protected]> | 2023-06-13 18:29:22 -0400 |
| commit | c7ad493b9ac3e2a6085ddfee0a33717de60845f2 (patch) | |
| tree | 71f44e3f2e45cfe2aa97df0c14f3a8e3cb7c4630 /components/libc/compilers | |
| parent | 6198eea6c751f2923cb46ad9a05b41e37fde3d3f (diff) | |
[libc][ctime] move null pointer check before dereference
This null check was redundant because the pointer timep was
dereferenced in any case.
Diffstat (limited to 'components/libc/compilers')
| -rw-r--r-- | components/libc/compilers/common/ctime.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/components/libc/compilers/common/ctime.c b/components/libc/compilers/common/ctime.c index dff9ac188e..f3e7de2229 100644 --- a/components/libc/compilers/common/ctime.c +++ b/components/libc/compilers/common/ctime.c @@ -177,7 +177,7 @@ static int set_timeval(struct timeval *tv) struct tm *gmtime_r(const time_t *timep, struct tm *r) { int i; - int work = *timep % (SPD); + int work; if(timep == RT_NULL || r == RT_NULL) { @@ -187,6 +187,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r) rt_memset(r, RT_NULL, sizeof(struct tm)); + work = *timep % (SPD); r->tm_sec = work % 60; work /= 60; r->tm_min = work % 60; |
