Skip to content

Commit ff5177f

Browse files
committed
[rtt] Fix all warnings
1 parent 747f5c2 commit ff5177f

File tree

20 files changed

+79
-27
lines changed

20 files changed

+79
-27
lines changed

examples/Blink/Blink.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#include <rtt.h>
22

3+
// NOTES: "CONFIG_USING_FINSH" and "CONFIG_USING_SPISD" in "rtt.h" may be turned off to save memory
4+
35
struct rt_thread blink_thread;
46
byte blink_thread_stack[1024];
57
bool led_state = false;
68

79
// user thread entry function
810
void blink_thread_entry(void* parameter) {
11+
(void)parameter;
12+
913
rt_kprintf("Start Blink\n");
1014

1115
// the loop is here

src/components/arduino/drv_spi.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ static rt_err_t bsp_spi_open(rt_device_t dev, rt_uint16_t oflag) {
8989
spi_debug("SPI%d: open with flag %x\n", ctx->chn, oflag);
9090
} while (0);
9191

92-
if (RT_EOK != ret)
92+
if (RT_EOK != ret) {
9393
spi_debug("SPI%d err: open failed [%08x]\n", ctx->chn, ret);
94+
}
9495
return ret;
9596
}
9697

@@ -105,8 +106,9 @@ static rt_err_t bsp_spi_close(rt_device_t dev) {
105106
spi_debug("SPI%d: closed\n", ctx->chn);
106107
} while (0);
107108

108-
if (RT_EOK != ret)
109+
if (RT_EOK != ret) {
109110
spi_debug("SPI%d err: close failed [%08x]\n", ctx->chn, ret);
111+
}
110112
return ret;
111113
}
112114

src/components/arduino/drv_spisd.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ static rt_err_t sd_read_block(struct bsp_sd_contex *ctx, void *buf,
250250
ret = RT_EOK;
251251
} while(0);
252252

253-
if (RT_EOK != ret)
253+
if (RT_EOK != ret) {
254254
sd_debug("SPISD err: read block failed! [%02x]\n", ret);
255+
}
255256
return ret;
256257
}
257258

@@ -429,8 +430,9 @@ static rt_err_t sd_write_block(struct bsp_sd_contex *ctx, void *buf,
429430
ret = RT_EOK;
430431
} while (0);
431432

432-
if (RT_EOK != ret)
433+
if (RT_EOK != ret) {
433434
sd_debug("SPISD err: write block failed! [%02x]\n", ret);
435+
}
434436
return ret;
435437
}
436438

@@ -521,8 +523,9 @@ static rt_err_t bsp_spiSd_init(rt_device_t dev) {
521523
SD_CS(0);
522524
rt_device_close(ctx->ldev);
523525

524-
if (RT_EOK != ret)
526+
if (RT_EOK != ret) {
525527
sd_debug("SPISD err: init failed! (%08x)\n", ret);
528+
}
526529
return ret;
527530
}
528531

@@ -537,7 +540,7 @@ static rt_size_t bsp_spiSd_read(rt_device_t dev, rt_off_t sector, void *buf,
537540
if (RT_EOK != err) {
538541
rt_set_errno(err);
539542
return 0;
540-
};
543+
}
541544
sd_debug("SPISD: read sect %d [%d]\n", sector, count);
542545

543546
/* convert to byte address if necessary */
@@ -803,9 +806,9 @@ static rt_err_t bsp_spiSd_control(rt_device_t dev, rt_int32_t cmd, void *buf) {
803806
break;
804807
}
805808

806-
if (RT_EOK != ret)
809+
if (RT_EOK != ret) {
807810
sd_debug("SPISD err: control failed! [%08x]\n", ret);
808-
811+
}
809812
return ret;
810813
}
811814

src/components/dfs/filesystems/elmfat/dfs_elm.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
102102
int index;
103103
struct rt_device_blk_geometry geometry;
104104
char logic_nbr[2] = {'0',':'};
105+
(void)rwflag;
106+
(void)data;
105107

106108
/* get an empty position */
107109
index = get_disk(RT_NULL);
@@ -476,6 +478,10 @@ int dfs_elm_close(struct dfs_fd *file)
476478

477479
int dfs_elm_ioctl(struct dfs_fd *file, int cmd, void *args)
478480
{
481+
(void)file;
482+
(void)cmd;
483+
(void)args;
484+
479485
return -ENOSYS;
480486
}
481487

@@ -653,6 +659,8 @@ int dfs_elm_unlink(struct dfs_filesystem *fs, const char *path)
653659
rt_snprintf(drivers_fn, 256, "%d:%s", vol, path);
654660
#else
655661
const char *drivers_fn;
662+
(void)fs;
663+
656664
drivers_fn = path;
657665
#endif
658666

@@ -686,6 +694,7 @@ int dfs_elm_rename(struct dfs_filesystem *fs, const char *oldpath, const char *n
686694
rt_snprintf(drivers_oldfn, 256, "%d:%s", vol, oldpath);
687695
#else
688696
const char *drivers_oldfn, *drivers_newfn;
697+
(void)fs;
689698

690699
drivers_oldfn = oldpath;
691700
drivers_newfn = newpath;
@@ -719,6 +728,8 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
719728
rt_snprintf(drivers_fn, 256, "%d:%s", vol, path);
720729
#else
721730
const char *drivers_fn;
731+
(void)fs;
732+
722733
drivers_fn = path;
723734
#endif
724735

@@ -824,12 +835,16 @@ INIT_COMPONENT_EXPORT(elm_init);
824835
/* Initialize a Drive */
825836
DSTATUS disk_initialize(BYTE drv)
826837
{
838+
(void)drv;
839+
827840
return 0;
828841
}
829842

830843
/* Return Disk Status */
831844
DSTATUS disk_status(BYTE drv)
832845
{
846+
(void)drv;
847+
833848
return 0;
834849
}
835850

src/components/dfs/src/dfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
134134
}
135135

136136
/* allocate a larger FD container */
137-
if (idx == fdt->maxfd && fdt->maxfd < DFS_FD_MAX)
137+
if (idx == (int)fdt->maxfd && fdt->maxfd < DFS_FD_MAX)
138138
{
139139
int cnt, index;
140140
struct dfs_fd **fds;
@@ -188,7 +188,7 @@ int fd_new(void)
188188
idx = fd_alloc(fdt, 0);
189189

190190
/* can't find an empty fd entry */
191-
if (idx == fdt->maxfd)
191+
if (idx == (int)fdt->maxfd)
192192
{
193193
idx = -(1 + DFS_FD_OFFSET);
194194
LOG_E( "DFS fd new is failed! Could not found an empty fd entry.");

src/components/dfs/src/dfs_posix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ int mkdir(const char *path, mode_t mode)
510510
int fd;
511511
struct dfs_fd *d;
512512
int result;
513+
(void)mode;
513514

514515
fd = fd_new();
515516
if (fd == -1)
@@ -872,6 +873,8 @@ FINSH_FUNCTION_EXPORT_ALIAS(chdir, cd, change current working directory);
872873
int access(const char *path, int amode)
873874
{
874875
struct stat sb;
876+
(void)amode;
877+
875878
if (stat(path, &sb) < 0)
876879
return -1; /* already sets errno */
877880

src/components/finsh/finsh_init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ int finsh_flush(struct finsh_parser* parser)
5050

5151
int finsh_reset(struct finsh_parser* parser)
5252
{
53+
(void)parser;
54+
5355
/* finsh init */
5456
finsh_node_init();
5557
finsh_var_init();

src/components/finsh/finsh_token.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
#if defined(RT_USING_FINSH) && !defined(FINSH_USING_MSH_ONLY)
1414

15-
#include "finsh.h"
1615
#include <stdlib.h>
16+
#include "finsh.h"
1717
#include "finsh_token.h"
1818
#include "finsh_error.h"
1919

20-
#define is_alpha(ch) ((ch | 0x20) - 'a') < 26u
20+
#define is_alpha(ch) ((ch | 0x20) - 'a') < 26
2121
#define is_digit(ch) ((ch) >= '0' && (ch) <= '9')
22-
#define is_xdigit(ch) (((ch) >= '0' && (ch) <= '9') || (((ch | 0x20) - 'a') < 6u))
22+
#define is_xdigit(ch) (((ch) >= '0' && (ch) <= '9') || (((ch | 0x20) - 'a') < 6))
2323
#define is_separator(ch) !(((ch) >= 'a' && (ch) <= 'z') \
2424
|| ((ch) >= 'A' && (ch) <= 'Z') || ((ch) >= '0' && (ch) <= '9') || ((ch) == '_'))
2525
#define is_eof(self) (self)->eof
@@ -298,7 +298,7 @@ static void token_run(struct finsh_token* self)
298298

299299
static int token_match_name(struct finsh_token* self, const char* str)
300300
{
301-
int i;
301+
unsigned int i;
302302

303303
for (i = 0; i < sizeof(finsh_name_table)/sizeof(struct name_table); i++)
304304
{
@@ -439,10 +439,10 @@ static int token_proc_escape(struct finsh_token* self)
439439
token_prev_char(self);
440440
break;
441441
default:
442-
if ( (ch - '0') < 8u)
442+
if ((ch - '0') < 8)
443443
{
444444
result = 0;
445-
while ( (ch - '0') < 8u )
445+
while ((ch - '0') < 8)
446446
{
447447
result = result*8 + ch - '0';
448448
ch = token_next_char(self);

src/components/finsh/shell.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ static char finsh_getchar(void)
152152
#ifndef RT_USING_POSIX
153153
static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size)
154154
{
155+
(void)dev;
156+
(void)size;
155157
RT_ASSERT(shell != RT_NULL);
156158

157159
/* release semaphore to let finsh thread rx data */
@@ -461,6 +463,7 @@ static void shell_push_history(struct finsh_shell *shell)
461463
void finsh_thread_entry(void *parameter)
462464
{
463465
char ch;
466+
(void)parameter;
464467

465468
/* normal is echo mode */
466469
#ifndef FINSH_ECHO_DISABLE_DEFAULT

src/kernel/idle.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ void rt_thread_idle_excute(void)
230230

231231
static void rt_thread_idle_entry(void *parameter)
232232
{
233+
(void)parameter;
234+
233235
#ifdef RT_USING_SMP
234236
if (rt_hw_cpu_id() != 0)
235237
{

0 commit comments

Comments
 (0)