summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authordongly <[email protected]>2022-08-03 00:09:49 +0800
committerGitHub <[email protected]>2022-08-02 12:09:49 -0400
commit3363586cbbf507937a6be74397f4ffd5c6966fe5 (patch)
tree8eaac87aa11b72c93a96b128d5a15134f097e95d /components
parent7882e42c614c24a1750cba4a3e2936b6bf68f42f (diff)
Fix some compilation warning (#5744)
* Fix some compilation warning * 补充修正一些数据类型的使用错误 Co-authored-by: Meco Man <[email protected]>
Diffstat (limited to 'components')
-rw-r--r--components/dfs/filesystems/romfs/dfs_romfs.c7
-rw-r--r--components/dfs/filesystems/romfs/romfs.c8
-rw-r--r--components/dfs/src/dfs.c8
-rw-r--r--components/drivers/i2c/i2c-bit-ops.c6
-rw-r--r--components/drivers/i2c/i2c_core.c6
-rw-r--r--components/drivers/serial/serial.c10
-rw-r--r--components/fal/src/fal_rtt.c6
-rw-r--r--components/net/netdev/src/netdev.c14
-rw-r--r--components/net/sal/src/sal_socket.c7
9 files changed, 39 insertions, 33 deletions
diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c
index 9e355471a8..1a467be242 100644
--- a/components/dfs/filesystems/romfs/dfs_romfs.c
+++ b/components/dfs/filesystems/romfs/dfs_romfs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -40,7 +40,7 @@ int dfs_romfs_ioctl(struct dfs_fd *file, int cmd, void *args)
rt_inline int check_dirent(struct romfs_dirent *dirent)
{
if ((dirent->type != ROMFS_DIRENT_FILE && dirent->type != ROMFS_DIRENT_DIR)
- || dirent->size == ~0)
+ || dirent->size == ~0U)
return -1;
return 0;
}
@@ -84,7 +84,7 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch
{
if (check_dirent(&dirent[index]) != 0)
return NULL;
- if (rt_strlen(dirent[index].name) == (subpath_end - subpath) &&
+ if (rt_strlen(dirent[index].name) == (rt_size_t)(subpath_end - subpath) &&
rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0)
{
dirent_size = dirent[index].size;
@@ -295,6 +295,7 @@ static const struct dfs_file_ops _rom_fops =
NULL,
dfs_romfs_lseek,
dfs_romfs_getdents,
+ NULL,
};
static const struct dfs_filesystem_ops _romfs =
{
diff --git a/components/dfs/filesystems/romfs/romfs.c b/components/dfs/filesystems/romfs/romfs.c
index 847fcc6e27..6897c23d5c 100644
--- a/components/dfs/filesystems/romfs/romfs.c
+++ b/components/dfs/filesystems/romfs/romfs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -10,17 +10,17 @@
#include <rtthread.h>
#include <dfs_romfs.h>
-const static unsigned char _dummy_dummy_txt[] =
+static const unsigned char _dummy_dummy_txt[] =
{
0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x21, 0x0d, 0x0a,
};
-const static struct romfs_dirent _dummy[] =
+static const struct romfs_dirent _dummy[] =
{
{ROMFS_DIRENT_FILE, "dummy.txt", _dummy_dummy_txt, sizeof(_dummy_dummy_txt)},
};
-const static unsigned char _dummy_txt[] =
+static const unsigned char _dummy_txt[] =
{
0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x21, 0x0d, 0x0a,
};
diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c
index 23cac5c9e9..5c542fdc9b 100644
--- a/components/dfs/src/dfs.c
+++ b/components/dfs/src/dfs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -132,7 +132,7 @@ static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
}
/* allocate a larger FD container */
- if (idx == fdt->maxfd && fdt->maxfd < DFS_FD_MAX)
+ if (idx == (int)fdt->maxfd && fdt->maxfd < DFS_FD_MAX)
{
int cnt, index;
struct dfs_fd **fds;
@@ -145,7 +145,7 @@ static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
if (fds == NULL) goto __exit; /* return fdt->maxfd */
/* clean the new allocated fds */
- for (index = fdt->maxfd; index < cnt; index ++)
+ for (index = (int)fdt->maxfd; index < cnt; index ++)
{
fds[index] = NULL;
}
@@ -186,7 +186,7 @@ int fd_new(void)
idx = fd_alloc(fdt, 0);
/* can't find an empty fd entry */
- if (idx == fdt->maxfd)
+ if (idx == (int)fdt->maxfd)
{
idx = -(1 + DFS_FD_OFFSET);
LOG_E("DFS fd new is failed! Could not found an empty fd entry.");
diff --git a/components/drivers/i2c/i2c-bit-ops.c b/components/drivers/i2c/i2c-bit-ops.c
index ae1f4db9c0..08fa5a836c 100644
--- a/components/drivers/i2c/i2c-bit-ops.c
+++ b/components/drivers/i2c/i2c-bit-ops.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -404,7 +404,9 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
{
ret = i2c_recv_bytes(bus, msg);
if (ret >= 1)
+ {
LOG_D("read %d byte%s", ret, ret == 1 ? "" : "s");
+ }
if (ret < msg->len)
{
if (ret >= 0)
@@ -416,7 +418,9 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
{
ret = i2c_send_bytes(bus, msg);
if (ret >= 1)
+ {
LOG_D("write %d byte%s", ret, ret == 1 ? "" : "s");
+ }
if (ret < msg->len)
{
if (ret >= 0)
diff --git a/components/drivers/i2c/i2c_core.c b/components/drivers/i2c/i2c_core.c
index c629765f65..39147be605 100644
--- a/components/drivers/i2c/i2c_core.c
+++ b/components/drivers/i2c/i2c_core.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -108,7 +108,7 @@ rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
const rt_uint8_t *buf,
rt_uint32_t count)
{
- rt_err_t ret;
+ rt_size_t ret;
struct rt_i2c_msg msg;
msg.addr = addr;
@@ -127,7 +127,7 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
rt_uint8_t *buf,
rt_uint32_t count)
{
- rt_err_t ret;
+ rt_size_t ret;
struct rt_i2c_msg msg;
RT_ASSERT(bus != RT_NULL);
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index d39acb298f..00d6671f37 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -200,7 +200,7 @@ static int serial_fops_poll(struct dfs_fd *fd, struct rt_pollreq *req)
return mask;
}
-const static struct dfs_file_ops _serial_fops =
+static const struct dfs_file_ops _serial_fops =
{
serial_fops_open,
serial_fops_close,
@@ -900,7 +900,7 @@ struct speed_baudrate_item
int baudrate;
};
-const static struct speed_baudrate_item _tbl[] =
+static const struct speed_baudrate_item _tbl[] =
{
{B2400, BAUD_RATE_2400},
{B4800, BAUD_RATE_4800},
@@ -918,7 +918,7 @@ const static struct speed_baudrate_item _tbl[] =
static speed_t _get_speed(int baudrate)
{
- int index;
+ size_t index;
for (index = 0; index < sizeof(_tbl)/sizeof(_tbl[0]); index ++)
{
@@ -931,7 +931,7 @@ static speed_t _get_speed(int baudrate)
static int _get_baudrate(speed_t speed)
{
- int index;
+ size_t index;
for (index = 0; index < sizeof(_tbl)/sizeof(_tbl[0]); index ++)
{
diff --git a/components/fal/src/fal_rtt.c b/components/fal/src/fal_rtt.c
index 3a014525b2..52d276d8c9 100644
--- a/components/fal/src/fal_rtt.c
+++ b/components/fal/src/fal_rtt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -264,7 +264,7 @@ static rt_err_t mtd_nor_dev_erase(struct rt_mtd_nor_device* device, rt_off_t off
ret = fal_partition_erase(part->fal_part, offset, length);
- if (ret != length)
+ if ((rt_uint32_t)ret != length || ret < 0)
{
return -RT_ERROR;
}
@@ -556,7 +556,7 @@ static void fal(uint8_t argc, char **argv) {
#define CMD_ERASE_INDEX 3
#define CMD_BENCH_INDEX 4
- int result;
+ int result = 0;
static const struct fal_flash_dev *flash_dev = NULL;
static const struct fal_partition *part_dev = NULL;
size_t i = 0, j = 0;
diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c
index 1009ace8d6..22be799ccc 100644
--- a/components/net/netdev/src/netdev.c
+++ b/components/net/netdev/src/netdev.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -28,9 +28,9 @@
#include <rtdbg.h>
/* The list of network interface device */
-struct netdev *netdev_list;
+struct netdev *netdev_list = RT_NULL;
/* The default network interface device */
-struct netdev *netdev_default;
+struct netdev *netdev_default = RT_NULL;
/**
* This function will register network interface device and
@@ -46,8 +46,8 @@ struct netdev *netdev_default;
int netdev_register(struct netdev *netdev, const char *name, void *user_data)
{
rt_base_t level;
- uint16_t flags_mask;
- int index;
+ rt_uint16_t flags_mask;
+ rt_uint16_t index;
RT_ASSERT(netdev);
RT_ASSERT(name);
@@ -706,7 +706,7 @@ void netdev_low_level_set_gw(struct netdev *netdev, const ip_addr_t *gw)
*/
void netdev_low_level_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_t *dns_server)
{
- int index;
+ unsigned int index;
RT_ASSERT(dns_server);
@@ -1173,7 +1173,7 @@ MSH_CMD_EXPORT_ALIAS(netdev_ping, ping, ping network host);
static void netdev_list_dns(void)
{
- int index = 0;
+ unsigned int index = 0;
struct netdev *netdev = RT_NULL;
rt_slist_t *node = RT_NULL;
diff --git a/components/net/sal/src/sal_socket.c b/components/net/sal/src/sal_socket.c
index 7e00ebf9bf..3256b9f4d6 100644
--- a/components/net/sal/src/sal_socket.c
+++ b/components/net/sal/src/sal_socket.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -158,7 +158,8 @@ static void check_netdev_internet_up_work(struct rt_work *work, void *work_data)
#define SAL_INTERNET_MONTH_LEN 4
#define SAL_INTERNET_DATE_LEN 16
- int index, sockfd = -1, result = 0;
+ unsigned int index;
+ int sockfd = -1, result = 0;
struct sockaddr_in server_addr;
struct hostent *host;
struct timeval timeout;
@@ -168,7 +169,7 @@ static void check_netdev_internet_up_work(struct rt_work *work, void *work_data)
const char month[][SAL_INTERNET_MONTH_LEN] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
char date[SAL_INTERNET_DATE_LEN];
- int moth_num = 0;
+ unsigned int moth_num = 0;
struct sal_proto_family *pf = (struct sal_proto_family *) netdev->sal_user_data;
const struct sal_socket_ops *skt_ops;