未验证 提交 a4829b1c 编写于 作者: 还_没_想_好's avatar 还_没_想_好 提交者: GitHub

[fix] Fix simulator compilation warnings (#6438)

* [fix] Fix simulator compilation warnings

* Update bsp/simulator/rtconfig_project.h
Co-authored-by: mysterywolf's avatarMan, Jianting (Meco) <920369182@qq.com>
上级 746d7a01
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#ifdef _MSC_VER #ifdef _MSC_VER
/* disable some warning in MSC */ /* disable some warning in MSC */
// #pragma warning(disable:4103) /* structure packing changed by including file */
// #pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */ // #pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */
#endif /* _MSC_VER */ #endif /* _MSC_VER */
......
...@@ -157,7 +157,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count) ...@@ -157,7 +157,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
int dfs_romfs_lseek(struct dfs_fd *file, off_t offset) int dfs_romfs_lseek(struct dfs_fd *file, off_t offset)
{ {
if (offset <= file->size) if (offset >= 0 && (rt_size_t)offset <= file->size)
{ {
file->pos = offset; file->pos = offset;
return file->pos; return file->pos;
...@@ -243,6 +243,7 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) ...@@ -243,6 +243,7 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count) int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
{ {
rt_size_t index; rt_size_t index;
rt_size_t len;
const char *name; const char *name;
struct dirent *d; struct dirent *d;
struct romfs_dirent *dirent, *sub_dirent; struct romfs_dirent *dirent, *sub_dirent;
...@@ -261,7 +262,7 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count) ...@@ -261,7 +262,7 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
return -EINVAL; return -EINVAL;
index = 0; index = 0;
for (index = 0; index < count && file->pos < file->size; index ++) for (index = 0; index < count && (rt_size_t)file->pos < file->size; index ++)
{ {
d = dirp + index; d = dirp + index;
...@@ -274,7 +275,9 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count) ...@@ -274,7 +275,9 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
else else
d->d_type = DT_REG; d->d_type = DT_REG;
d->d_namlen = rt_strlen(name); len = rt_strlen(name);
RT_ASSERT(len <= RT_UINT8_MAX);
d->d_namlen = (rt_uint8_t)len;
d->d_reclen = (rt_uint16_t)sizeof(struct dirent); d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
rt_strncpy(d->d_name, name, DFS_PATH_MAX); rt_strncpy(d->d_name, name, DFS_PATH_MAX);
......
...@@ -231,7 +231,7 @@ static rt_err_t rt_hwtimer_control(struct rt_device *dev, int cmd, void *args) ...@@ -231,7 +231,7 @@ static rt_err_t rt_hwtimer_control(struct rt_device *dev, int cmd, void *args)
break; break;
case HWTIMER_CTRL_FREQ_SET: case HWTIMER_CTRL_FREQ_SET:
{ {
rt_uint32_t *f; rt_int32_t *f;
if (args == RT_NULL) if (args == RT_NULL)
{ {
...@@ -239,7 +239,7 @@ static rt_err_t rt_hwtimer_control(struct rt_device *dev, int cmd, void *args) ...@@ -239,7 +239,7 @@ static rt_err_t rt_hwtimer_control(struct rt_device *dev, int cmd, void *args)
break; break;
} }
f = (rt_uint32_t*)args; f = (rt_int32_t*)args;
if ((*f > timer->info->maxfreq) || (*f < timer->info->minfreq)) if ((*f > timer->info->maxfreq) || (*f < timer->info->minfreq))
{ {
LOG_W("frequency setting out of range! It will maintain at %d Hz", timer->freq); LOG_W("frequency setting out of range! It will maintain at %d Hz", timer->freq);
......
...@@ -372,7 +372,8 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus, ...@@ -372,7 +372,8 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
{ {
struct rt_i2c_msg *msg; struct rt_i2c_msg *msg;
struct rt_i2c_bit_ops *ops = (struct rt_i2c_bit_ops *)bus->priv; struct rt_i2c_bit_ops *ops = (struct rt_i2c_bit_ops *)bus->priv;
rt_int32_t i, ret; rt_int32_t ret;
rt_uint32_t i;
rt_uint16_t ignore_nack; rt_uint16_t ignore_nack;
if (num == 0) return 0; if (num == 0) return 0;
......
...@@ -95,7 +95,7 @@ rt_inline rt_uint16_t rt_ringbuffer_get_size(struct rt_ringbuffer *rb) ...@@ -95,7 +95,7 @@ rt_inline rt_uint16_t rt_ringbuffer_get_size(struct rt_ringbuffer *rb)
} }
/** return the size of empty space in rb */ /** return the size of empty space in rb */
#define rt_ringbuffer_space_len(rb) ((rb)->buffer_size - rt_ringbuffer_data_len(rb)) #define rt_ringbuffer_space_len(rb) ((rb)->buffer_size - (rt_int16_t)rt_ringbuffer_data_len(rb))
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -497,7 +497,7 @@ static rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt ...@@ -497,7 +497,7 @@ static rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt
while (read_bytes < count) while (read_bytes < count)
{ {
int len = rt_ringbuffer_get(pipe->fifo, &pbuf[read_bytes], count - read_bytes); int len = rt_ringbuffer_get(pipe->fifo, &pbuf[read_bytes], (rt_uint16_t)(count - read_bytes));
if (len <= 0) break; if (len <= 0) break;
read_bytes += len; read_bytes += len;
...@@ -539,7 +539,7 @@ static rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buf ...@@ -539,7 +539,7 @@ static rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buf
while (write_bytes < count) while (write_bytes < count)
{ {
int len = rt_ringbuffer_put(pipe->fifo, &pbuf[write_bytes], count - write_bytes); int len = rt_ringbuffer_put(pipe->fifo, &pbuf[write_bytes], (rt_uint16_t)(count - write_bytes));
if (len <= 0) break; if (len <= 0) break;
write_bytes += len; write_bytes += len;
......
...@@ -192,7 +192,7 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb, ...@@ -192,7 +192,7 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb,
/* less data */ /* less data */
if (size < length) if (size < length)
length = size; length = (rt_uint16_t)size;
if (rb->buffer_size - rb->read_index > length) if (rb->buffer_size - rb->read_index > length)
{ {
...@@ -248,7 +248,7 @@ rt_size_t rt_ringbuffer_peek(struct rt_ringbuffer *rb, rt_uint8_t **ptr) ...@@ -248,7 +248,7 @@ rt_size_t rt_ringbuffer_peek(struct rt_ringbuffer *rb, rt_uint8_t **ptr)
if ((rt_size_t)(rb->buffer_size - rb->read_index) > size) if ((rt_size_t)(rb->buffer_size - rb->read_index) > size)
{ {
rb->read_index += size; rb->read_index += (rt_uint16_t)size;
return size; return size;
} }
......
...@@ -162,7 +162,7 @@ rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device *device, rt_uint32_ ...@@ -162,7 +162,7 @@ rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device *device, rt_uint32_
#include <finsh.h> #include <finsh.h>
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ') #define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
static void mtd_dump_hex(const rt_uint8_t *ptr, rt_size_t buflen) static void mtd_dump_hex(const rt_uint8_t *ptr, int buflen)
{ {
unsigned char *buf = (unsigned char *)ptr; unsigned char *buf = (unsigned char *)ptr;
int i, j; int i, j;
......
...@@ -424,7 +424,7 @@ static struct mmcsd_blk_device * rt_mmcsd_create_blkdev(struct rt_mmcsd_card *ca ...@@ -424,7 +424,7 @@ static struct mmcsd_blk_device * rt_mmcsd_create_blkdev(struct rt_mmcsd_card *ca
rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
{ {
rt_int32_t err = 0; rt_int32_t err = 0;
rt_uint8_t status; rt_err_t status;
rt_uint8_t *sector; rt_uint8_t *sector;
err = mmcsd_set_blksize(card); err = mmcsd_set_blksize(card);
......
...@@ -196,7 +196,7 @@ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) ...@@ -196,7 +196,7 @@ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd)
card_capacity = *((rt_uint32_t *)&ext_csd[EXT_CSD_SEC_CNT]); card_capacity = *((rt_uint32_t *)&ext_csd[EXT_CSD_SEC_CNT]);
card_capacity *= card->card_blksize; card_capacity *= card->card_blksize;
card_capacity >>= 10; /* unit:KB */ card_capacity >>= 10; /* unit:KB */
card->card_capacity = card_capacity; card->card_capacity = (rt_uint32_t)card_capacity;
LOG_I("emmc card capacity %d KB.", card->card_capacity); LOG_I("emmc card capacity %d KB.", card->card_capacity);
return 0; return 0;
......
...@@ -284,8 +284,7 @@ rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host, ...@@ -284,8 +284,7 @@ rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host,
int retry) int retry)
{ {
struct rt_mmcsd_req req; struct rt_mmcsd_req req;
int i;
rt_uint32_t i;
rt_err_t err; rt_err_t err;
err = -RT_ERROR; err = -RT_ERROR;
...@@ -294,7 +293,7 @@ rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host, ...@@ -294,7 +293,7 @@ rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host,
* We have to resend MMC_APP_CMD for each attempt so * We have to resend MMC_APP_CMD for each attempt so
* we cannot use the retries field in mmc_command. * we cannot use the retries field in mmc_command.
*/ */
for (i = 0;i <= retry;i++) for (i = 0; i <= retry; i++)
{ {
rt_memset(&req, 0, sizeof(struct rt_mmcsd_req)); rt_memset(&req, 0, sizeof(struct rt_mmcsd_req));
......
...@@ -424,7 +424,7 @@ static void rt_dma_recv_update_get_index(struct rt_serial_device *serial, rt_siz ...@@ -424,7 +424,7 @@ static void rt_dma_recv_update_get_index(struct rt_serial_device *serial, rt_siz
if (rx_fifo->is_full && len != 0) rx_fifo->is_full = RT_FALSE; if (rx_fifo->is_full && len != 0) rx_fifo->is_full = RT_FALSE;
rx_fifo->get_index += len; rx_fifo->get_index += (rt_uint16_t)len;
if (rx_fifo->get_index >= serial->config.bufsz) if (rx_fifo->get_index >= serial->config.bufsz)
{ {
rx_fifo->get_index %= serial->config.bufsz; rx_fifo->get_index %= serial->config.bufsz;
...@@ -445,7 +445,7 @@ static void rt_dma_recv_update_put_index(struct rt_serial_device *serial, rt_siz ...@@ -445,7 +445,7 @@ static void rt_dma_recv_update_put_index(struct rt_serial_device *serial, rt_siz
if (rx_fifo->get_index <= rx_fifo->put_index) if (rx_fifo->get_index <= rx_fifo->put_index)
{ {
rx_fifo->put_index += len; rx_fifo->put_index += (rt_uint16_t)len;
/* beyond the fifo end */ /* beyond the fifo end */
if (rx_fifo->put_index >= serial->config.bufsz) if (rx_fifo->put_index >= serial->config.bufsz)
{ {
...@@ -459,7 +459,7 @@ static void rt_dma_recv_update_put_index(struct rt_serial_device *serial, rt_siz ...@@ -459,7 +459,7 @@ static void rt_dma_recv_update_put_index(struct rt_serial_device *serial, rt_siz
} }
else else
{ {
rx_fifo->put_index += len; rx_fifo->put_index += (rt_uint16_t)len;
if (rx_fifo->put_index >= rx_fifo->get_index) if (rx_fifo->put_index >= rx_fifo->get_index)
{ {
/* beyond the fifo end */ /* beyond the fifo end */
......
...@@ -218,7 +218,7 @@ int rt_hw_touch_register(rt_touch_t touch, ...@@ -218,7 +218,7 @@ int rt_hw_touch_register(rt_touch_t touch,
rt_uint32_t flag, rt_uint32_t flag,
void *data) void *data)
{ {
rt_int8_t result; rt_err_t result;
rt_device_t device; rt_device_t device;
RT_ASSERT(touch != RT_NULL); RT_ASSERT(touch != RT_NULL);
......
...@@ -84,9 +84,9 @@ char *ltoa(long value, char *string, int radix) ...@@ -84,9 +84,9 @@ char *ltoa(long value, char *string, int radix)
i = v % radix; i = v % radix;
v = v / radix; v = v / radix;
if (i < 10) if (i < 10)
*tp++ = i+'0'; *tp++ = (char)(i+'0');
else else
*tp++ = i + 'a' - 10; *tp++ = (char)(i + 'a' - 10);
} }
sp = string; sp = string;
...@@ -129,9 +129,9 @@ char *ultoa(unsigned long value, char *string, int radix) ...@@ -129,9 +129,9 @@ char *ultoa(unsigned long value, char *string, int radix)
i = v % radix; i = v % radix;
v = v / radix; v = v / radix;
if (i < 10) if (i < 10)
*tp++ = i+'0'; *tp++ = (char)(i+'0');
else else
*tp++ = i + 'a' - 10; *tp++ = (char)(i + 'a' - 10);
} }
sp = string; sp = string;
......
...@@ -171,8 +171,8 @@ static int set_timeval(struct timeval *tv) ...@@ -171,8 +171,8 @@ static int set_timeval(struct timeval *tv)
struct tm *gmtime_r(const time_t *timep, struct tm *r) struct tm *gmtime_r(const time_t *timep, struct tm *r)
{ {
time_t i; int i;
time_t work = *timep % (SPD); int work = *timep % (SPD);
if(timep == RT_NULL || r == RT_NULL) if(timep == RT_NULL || r == RT_NULL)
{ {
...@@ -186,11 +186,11 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r) ...@@ -186,11 +186,11 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r)
work /= 60; work /= 60;
r->tm_min = work % 60; r->tm_min = work % 60;
r->tm_hour = work / 60; r->tm_hour = work / 60;
work = *timep / (SPD); work = (int)(*timep / (SPD));
r->tm_wday = (4 + work) % 7; r->tm_wday = (4 + work) % 7;
for (i = 1970;; ++i) for (i = 1970;; ++i)
{ {
time_t k = __isleap(i) ? 366 : 365; int k = __isleap(i) ? 366 : 365;
if (work >= k) if (work >= k)
work -= k; work -= k;
else else
...@@ -468,7 +468,7 @@ time_t timegm(struct tm * const t) ...@@ -468,7 +468,7 @@ time_t timegm(struct tm * const t)
/* day is now the number of days since 'Jan 1 1970' */ /* day is now the number of days since 'Jan 1 1970' */
i = 7; i = 7;
t->tm_wday = (day + 4) % i; /* Sunday=0, Monday=1, ..., Saturday=6 */ t->tm_wday = (int)((day + 4) % i); /* Sunday=0, Monday=1, ..., Saturday=6 */
i = 24; i = 24;
day *= i; day *= i;
......
...@@ -100,7 +100,7 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struc ...@@ -100,7 +100,7 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struc
/* Convert the timeout to milliseconds */ /* Convert the timeout to milliseconds */
if (timeout) if (timeout)
{ {
msec = timeout->tv_sec * 1000 + timeout->tv_usec / 1000; msec = (int)timeout->tv_sec * 1000 + (int)timeout->tv_usec / 1000;
} }
else else
{ {
......
...@@ -475,6 +475,10 @@ static err_t eth_netif_device_init(struct netif *netif) ...@@ -475,6 +475,10 @@ static err_t eth_netif_device_init(struct netif *netif)
/* get device object */ /* get device object */
device = (rt_device_t) ethif; device = (rt_device_t) ethif;
if (rt_device_init(device) != RT_EOK)
{
return ERR_IF;
}
if (rt_device_open(device, RT_DEVICE_FLAG_RDWR) != RT_EOK) if (rt_device_open(device, RT_DEVICE_FLAG_RDWR) != RT_EOK)
{ {
return ERR_IF; return ERR_IF;
...@@ -910,7 +914,7 @@ FINSH_FUNCTION_EXPORT(set_dns, set DNS server address); ...@@ -910,7 +914,7 @@ FINSH_FUNCTION_EXPORT(set_dns, set DNS server address);
void list_if(void) void list_if(void)
{ {
rt_ubase_t index; rt_uint8_t index;
struct netif * netif; struct netif * netif;
rt_enter_critical(); rt_enter_critical();
......
...@@ -18,21 +18,21 @@ ...@@ -18,21 +18,21 @@
#define RT_LINK_AUTO_INIT #define RT_LINK_AUTO_INIT
#define RT_LINK_FLAG_ACK 0x01 #define RT_LINK_FLAG_ACK 0x01U
#define RT_LINK_FLAG_CRC 0x02 #define RT_LINK_FLAG_CRC 0x02U
#define RT_LINK_FRAME_HEAD 0x15 #define RT_LINK_FRAME_HEAD 0x15U
#define RT_LINK_FRAME_HEAD_MASK 0x1F #define RT_LINK_FRAME_HEAD_MASK 0x1FU
/* The maximum number of split frames for a long package */ /* The maximum number of split frames for a long package */
#define RT_LINK_FRAMES_MAX 0x03 #define RT_LINK_FRAMES_MAX 0x03U
/* The length in the rt_link_frame_head structure occupies 11 bits, /* The length in the rt_link_frame_head structure occupies 11 bits,
so the value range after 4-byte alignment is 0-2044.*/ so the value range after 4-byte alignment is 0-2044.*/
#define RT_LINK_MAX_FRAME_LENGTH 1024 #define RT_LINK_MAX_FRAME_LENGTH 1024U
#define RT_LINK_ACK_MAX 0x07 #define RT_LINK_ACK_MAX 0x07U
#define RT_LINK_CRC_LENGTH 4 #define RT_LINK_CRC_LENGTH 4U
#define RT_LINK_HEAD_LENGTH 4 #define RT_LINK_HEAD_LENGTH 4U
#define RT_LINK_EXTEND_LENGTH 4 #define RT_LINK_EXTEND_LENGTH 4U
#define RT_LINK_MAX_DATA_LENGTH (RT_LINK_MAX_FRAME_LENGTH - \ #define RT_LINK_MAX_DATA_LENGTH (RT_LINK_MAX_FRAME_LENGTH - \
RT_LINK_HEAD_LENGTH - \ RT_LINK_HEAD_LENGTH - \
......
...@@ -70,7 +70,7 @@ struct rt_link_session *rt_link_get_scb(void) ...@@ -70,7 +70,7 @@ struct rt_link_session *rt_link_get_scb(void)
return rt_link_scb; return rt_link_scb;
} }
static rt_int16_t rt_link_check_seq(rt_uint8_t new, rt_uint8_t used) static rt_uint8_t rt_link_check_seq(rt_uint8_t new, rt_uint8_t used)
{ {
rt_int16_t compare_seq = 0; rt_int16_t compare_seq = 0;
compare_seq = new - used; compare_seq = new - used;
...@@ -78,7 +78,7 @@ static rt_int16_t rt_link_check_seq(rt_uint8_t new, rt_uint8_t used) ...@@ -78,7 +78,7 @@ static rt_int16_t rt_link_check_seq(rt_uint8_t new, rt_uint8_t used)
{ {
compare_seq = compare_seq + 256; compare_seq = compare_seq + 256;
} }
return compare_seq; return (rt_uint8_t)compare_seq;
} }
static int rt_link_frame_init(struct rt_link_frame *frame, rt_uint8_t config) static int rt_link_frame_init(struct rt_link_frame *frame, rt_uint8_t config)
...@@ -157,7 +157,7 @@ static rt_err_t rt_link_frame_extend_config(struct rt_link_frame *frame, rt_link ...@@ -157,7 +157,7 @@ static rt_err_t rt_link_frame_extend_config(struct rt_link_frame *frame, rt_link
return RT_EOK; return RT_EOK;
} }
static int rt_link_command_frame_send(rt_uint8_t serv, rt_uint8_t sequence, rt_link_frame_attr_e attribute, rt_uint16_t parameter) static int rt_link_command_frame_send(rt_uint16_t serv, rt_uint8_t sequence, rt_link_frame_attr_e attribute, rt_uint16_t parameter)
{ {
struct rt_link_frame command_frame = {0}; struct rt_link_frame command_frame = {0};
rt_uint8_t data[sizeof(command_frame.head) + sizeof(command_frame.extend)] = {0}; rt_uint8_t data[sizeof(command_frame.head) + sizeof(command_frame.extend)] = {0};
...@@ -182,7 +182,7 @@ static int rt_link_command_frame_send(rt_uint8_t serv, rt_uint8_t sequence, rt_l ...@@ -182,7 +182,7 @@ static int rt_link_command_frame_send(rt_uint8_t serv, rt_uint8_t sequence, rt_l
static void rt_link_service_send_finish(rt_link_err_e err) static void rt_link_service_send_finish(rt_link_err_e err)
{ {
struct rt_link_frame *frame = RT_NULL; struct rt_link_frame *frame = RT_NULL;
rt_uint8_t service = RT_LINK_SERVICE_MAX; rt_uint16_t service = RT_LINK_SERVICE_MAX;
void *buffer = RT_NULL; void *buffer = RT_NULL;
rt_slist_t *tem_list = rt_slist_first(&rt_link_scb->tx_data_slist); rt_slist_t *tem_list = rt_slist_first(&rt_link_scb->tx_data_slist);
if (tem_list == RT_NULL) if (tem_list == RT_NULL)
...@@ -416,7 +416,7 @@ static rt_err_t rt_link_confirm_handle(struct rt_link_frame *receive_frame) ...@@ -416,7 +416,7 @@ static rt_err_t rt_link_confirm_handle(struct rt_link_frame *receive_frame)
} }
/* serv type rt_link_service_e */ /* serv type rt_link_service_e */
static void rt_link_recv_finish(rt_uint8_t serv, void *data, rt_size_t size) static void rt_link_recv_finish(rt_uint16_t serv, void *data, rt_size_t size)
{ {
if (rt_link_scb->service[serv] == RT_NULL) if (rt_link_scb->service[serv] == RT_NULL)
{ {
...@@ -570,7 +570,7 @@ static rt_err_t rt_link_handshake_handle(struct rt_link_frame *receive_frame) ...@@ -570,7 +570,7 @@ static rt_err_t rt_link_handshake_handle(struct rt_link_frame *receive_frame)
/* sync requester tx seq, responder rx seq = requester tx seq */ /* sync requester tx seq, responder rx seq = requester tx seq */
rt_link_scb->rx_record.rx_seq = receive_frame->head.sequence; rt_link_scb->rx_record.rx_seq = receive_frame->head.sequence;
/* sync requester rx seq, responder tx seq = requester rx seq */ /* sync requester rx seq, responder tx seq = requester rx seq */
rt_link_scb->tx_seq = receive_frame->extend.parameter; rt_link_scb->tx_seq = (rt_uint8_t)receive_frame->extend.parameter;
if (rt_link_scb->service[receive_frame->head.service] != RT_NULL) if (rt_link_scb->service[receive_frame->head.service] != RT_NULL)
{ {
...@@ -1042,11 +1042,11 @@ rt_size_t rt_link_send(struct rt_link_service *service, const void *data, rt_siz ...@@ -1042,11 +1042,11 @@ rt_size_t rt_link_send(struct rt_link_service *service, const void *data, rt_siz
service->err = RT_LINK_EOK; service->err = RT_LINK_EOK;
if (size % RT_LINK_MAX_DATA_LENGTH == 0) if (size % RT_LINK_MAX_DATA_LENGTH == 0)
{ {
total = size / RT_LINK_MAX_DATA_LENGTH; total = (rt_uint8_t)(size / RT_LINK_MAX_DATA_LENGTH);
} }
else else
{ {
total = size / RT_LINK_MAX_DATA_LENGTH + 1; total = (rt_uint8_t)(size / RT_LINK_MAX_DATA_LENGTH + 1);
} }
if (total > RT_LINK_FRAMES_MAX) if (total > RT_LINK_FRAMES_MAX)
...@@ -1079,7 +1079,7 @@ rt_size_t rt_link_send(struct rt_link_service *service, const void *data, rt_siz ...@@ -1079,7 +1079,7 @@ rt_size_t rt_link_send(struct rt_link_service *service, const void *data, rt_siz
send_frame->attribute = RT_LINK_LONG_DATA_FRAME; send_frame->attribute = RT_LINK_LONG_DATA_FRAME;
if (offset + RT_LINK_MAX_DATA_LENGTH > size) if (offset + RT_LINK_MAX_DATA_LENGTH > size)
{ {
send_frame->data_len = size - offset; send_frame->data_len = (rt_uint16_t)(size - offset);
} }
else else
{ {
...@@ -1087,12 +1087,12 @@ rt_size_t rt_link_send(struct rt_link_service *service, const void *data, rt_siz ...@@ -1087,12 +1087,12 @@ rt_size_t rt_link_send(struct rt_link_service *service, const void *data, rt_siz
offset += RT_LINK_MAX_DATA_LENGTH; offset += RT_LINK_MAX_DATA_LENGTH;
} }
rt_link_frame_extend_config(send_frame, RT_LINK_LONG_DATA_FRAME, size); rt_link_frame_extend_config(send_frame, RT_LINK_LONG_DATA_FRAME, (rt_uint16_t)size);
} }
else else
{ {
send_frame->attribute = RT_LINK_SHORT_DATA_FRAME; send_frame->attribute = RT_LINK_SHORT_DATA_FRAME;
send_frame->data_len = size; send_frame->data_len = (rt_uint16_t)size;
} }
/* append the frame on the tail of list */ /* append the frame on the tail of list */
......
...@@ -47,7 +47,7 @@ struct rt_link_receive_buffer *rt_link_hw_buffer_init(void *parameter) ...@@ -47,7 +47,7 @@ struct rt_link_receive_buffer *rt_link_hw_buffer_init(void *parameter)
static rt_size_t rt_link_hw_buffer_write(void *data, rt_size_t count) static rt_size_t rt_link_hw_buffer_write(void *data, rt_size_t count)
{ {
int surplus = 0; rt_size_t surplus = 0;
if (rx_buffer == RT_NULL) if (rx_buffer == RT_NULL)
{ {
return 0; return 0;
......
...@@ -522,7 +522,7 @@ static void do_output(rt_uint32_t level, const char *tag, rt_bool_t is_raw, cons ...@@ -522,7 +522,7 @@ static void do_output(rt_uint32_t level, const char *tag, rt_bool_t is_raw, cons
} }
else if (ulog.async_rb) else if (ulog.async_rb)
{ {
rt_ringbuffer_put(ulog.async_rb, (const rt_uint8_t *)log_buf, log_buf_size); rt_ringbuffer_put(ulog.async_rb, (const rt_uint8_t *)log_buf, (rt_uint16_t)log_buf_size);
/* send a notice */ /* send a notice */
rt_sem_release(&ulog.async_notice); rt_sem_release(&ulog.async_notice);
} }
...@@ -1405,7 +1405,7 @@ void ulog_async_output(void) ...@@ -1405,7 +1405,7 @@ void ulog_async_output(void)
char *log = rt_malloc(log_len + 1); char *log = rt_malloc(log_len + 1);
if (log) if (log)
{ {
rt_size_t len = rt_ringbuffer_get(ulog.async_rb, (rt_uint8_t *)log, log_len); rt_size_t len = rt_ringbuffer_get(ulog.async_rb, (rt_uint8_t *)log, (rt_uint16_t)log_len);
log[log_len] = '\0'; log[log_len] = '\0';
ulog_output_to_all_backend(LOG_LVL_DBG, "", RT_TRUE, log, len); ulog_output_to_all_backend(LOG_LVL_DBG, "", RT_TRUE, log, len);
rt_free(log); rt_free(log);
......
...@@ -1797,7 +1797,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb, ...@@ -1797,7 +1797,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb,
/* initialize mailbox */ /* initialize mailbox */
mb->msg_pool = (rt_ubase_t *)msgpool; mb->msg_pool = (rt_ubase_t *)msgpool;
mb->size = size; mb->size = (rt_uint16_t)size;
mb->entry = 0; mb->entry = 0;
mb->in_offset = 0; mb->in_offset = 0;
mb->out_offset = 0; mb->out_offset = 0;
...@@ -1899,7 +1899,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag) ...@@ -1899,7 +1899,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
_ipc_object_init(&(mb->parent)); _ipc_object_init(&(mb->parent));
/* initialize mailbox */ /* initialize mailbox */
mb->size = size; mb->size = (rt_uint16_t)size;
mb->msg_pool = (rt_ubase_t *)RT_KERNEL_MALLOC(mb->size * sizeof(rt_ubase_t)); mb->msg_pool = (rt_ubase_t *)RT_KERNEL_MALLOC(mb->size * sizeof(rt_ubase_t));
if (mb->msg_pool == RT_NULL) if (mb->msg_pool == RT_NULL)
{ {
...@@ -2511,7 +2511,7 @@ rt_err_t rt_mq_init(rt_mq_t mq, ...@@ -2511,7 +2511,7 @@ rt_err_t rt_mq_init(rt_mq_t mq,
/* get correct message size */ /* get correct message size */
mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE); mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE);
mq->max_msgs = pool_size / (mq->msg_size + sizeof(struct rt_mq_message)); mq->max_msgs = (rt_uint16_t)(pool_size / (mq->msg_size + sizeof(struct rt_mq_message)));
/* initialize message list */ /* initialize message list */
mq->msg_queue_head = RT_NULL; mq->msg_queue_head = RT_NULL;
...@@ -2636,7 +2636,7 @@ rt_mq_t rt_mq_create(const char *name, ...@@ -2636,7 +2636,7 @@ rt_mq_t rt_mq_create(const char *name,
/* get correct message size */ /* get correct message size */
mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE); mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE);
mq->max_msgs = max_msgs; mq->max_msgs = (rt_uint16_t)max_msgs;
/* allocate message pool */ /* allocate message pool */
mq->msg_pool = RT_KERNEL_MALLOC((mq->msg_size + sizeof(struct rt_mq_message)) * mq->max_msgs); mq->msg_pool = RT_KERNEL_MALLOC((mq->msg_size + sizeof(struct rt_mq_message)) * mq->max_msgs);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册