From 396b7da6fd35828d97ada728947f81b6cad478e5 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 13 Oct 2021 23:18:55 -0400 Subject: [PATCH] [libc][time] Ensure the data types are consistent --- components/drivers/src/ringbuffer.c | 2 +- components/libc/compilers/common/time.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c index 3e76b1774a..e33f533db0 100644 --- a/components/drivers/src/ringbuffer.c +++ b/components/drivers/src/ringbuffer.c @@ -244,7 +244,7 @@ rt_size_t rt_ringbuffer_peak(struct rt_ringbuffer *rb, rt_uint8_t **ptr) *ptr = &rb->buffer_ptr[rb->read_index]; - if(rb->buffer_size - rb->read_index > size) + if((rt_size_t)(rb->buffer_size - rb->read_index) > size) { rb->read_index += size; return size; diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 24289088fb..5bfff15914 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -240,7 +240,7 @@ RTM_EXPORT(mktime); char* asctime_r(const struct tm *t, char *buf) { /* Checking input validity */ - if (rt_strlen(days) <= (t->tm_wday << 2) || rt_strlen(months) <= (t->tm_mon << 2)) + if ((int)rt_strlen(days) <= (t->tm_wday << 2) || (int)rt_strlen(months) <= (t->tm_mon << 2)) { LOG_W("asctime_r: the input parameters exceeded the limit, please check it."); *(int*) buf = *(int*) days; -- GitLab