Browse Source

fixed unused parameter warning

(void) parameter cast is a common way to suppress unused warning
pull/27/head
Vitus Birkmeir 3 years ago
parent
commit
fe9ec960b4
  1. 19
      ftpd.c
  2. 3
      test-in-docker/src/main.c
  3. 12
      vfs.c

19
ftpd.c

@ -525,6 +525,7 @@ static void send_next_directory(struct ftpd_datastate *fsd, struct tcp_pcb *pcb,
static err_t ftpd_datasent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
struct ftpd_datastate *fsd = arg;
(void) len; /* suppress unused warning */
switch (fsd->msgfs->state) {
case FTPD_LIST:
@ -587,6 +588,7 @@ static err_t ftpd_datarecv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t
static err_t ftpd_dataconnected(void *arg, struct tcp_pcb *pcb, err_t err)
{
struct ftpd_datastate *fsd = arg;
(void) err; /* suppress unused warning */
fsd->msgfs->datapcb = pcb;
fsd->connected = 1;
@ -622,6 +624,8 @@ static err_t ftpd_dataaccept(void *arg, struct tcp_pcb *pcb, err_t err)
{
struct ftpd_datastate *fsd = arg;
(void) err; /* suppress unused warning */
fsd->msgfs->datapcb = pcb;
fsd->connected = 1;
@ -698,6 +702,8 @@ static int open_dataconnection(struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
static void cmd_user(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
(void) arg; /* suppress unused warning */
send_msg(pcb, fsm, msg331);
fsm->state = FTPD_PASS;
/*
@ -708,6 +714,7 @@ static void cmd_user(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate
static void cmd_pass(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
(void) arg; /* suppress unused warning */
send_msg(pcb, fsm, msg230);
fsm->state = FTPD_IDLE;
/*
@ -734,6 +741,7 @@ static void cmd_port(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate
static void cmd_quit(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
(void) arg; /* suppress unused warning */
send_msg(pcb, fsm, msg221);
fsm->state = FTPD_QUIT;
}
@ -749,6 +757,7 @@ static void cmd_cwd(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *
static void cmd_cdup(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
(void) arg; /* suppress unused warning */
if (!vfs_chdir(fsm->vfs, "..")) {
send_msg(pcb, fsm, msg250);
} else {
@ -759,6 +768,7 @@ static void cmd_cdup(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate
static void cmd_pwd(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
char *path;
(void) arg; /* suppress unused warning */
if ((path = vfs_getcwd(fsm->vfs, NULL, 0))) {
send_msg(pcb, fsm, msg257PWD, path);
@ -770,6 +780,7 @@ static void cmd_list_common(const char *arg, struct tcp_pcb *pcb, struct ftpd_ms
{
vfs_dir_t *vfs_dir;
char *cwd;
(void) arg; /* suppress unused warning */
cwd = vfs_getcwd(fsm->vfs, NULL, 0);
if ((!cwd)) {
@ -858,11 +869,13 @@ static void cmd_stor(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate
static void cmd_noop(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
(void) arg; /* suppress unused warning */
send_msg(pcb, fsm, msg200);
}
static void cmd_syst(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
(void) arg; /* suppress unused warning */
send_msg(pcb, fsm, msg214SYST, "UNIX");
}
@ -871,6 +884,7 @@ static void cmd_pasv(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate
static u16_t port = 4096;
static u16_t start_port = 4096;
struct tcp_pcb *temppcb;
(void) arg; /* suppress unused warning */
/* Allocate memory for the structure that holds the state of the
connection. */
@ -946,6 +960,7 @@ static void cmd_pasv(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate
static void cmd_abrt(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
(void) arg; /* suppress unused warning */
if (fsm->datafs != NULL) {
tcp_arg(fsm->datapcb, NULL);
tcp_sent(fsm->datapcb, NULL);
@ -1220,6 +1235,7 @@ static void ftpd_msgclose(struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
static err_t ftpd_msgsent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
struct ftpd_msgstate *fsm = arg;
(void) len; /* suppress unused warning */
if ((sfifo_used(&fsm->fifo) == 0) && (fsm->state == FTPD_QUIT)) {
ftpd_msgclose(pcb, fsm);
@ -1292,6 +1308,7 @@ static err_t ftpd_msgrecv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t
static err_t ftpd_msgpoll(void *arg, struct tcp_pcb *pcb)
{
struct ftpd_msgstate *fsm = arg;
(void) pcb; /* suppress unused warning */
if (fsm == NULL)
return ERR_OK;
@ -1321,6 +1338,8 @@ static err_t ftpd_msgaccept(void *arg, struct tcp_pcb *pcb, err_t err)
{
LWIP_PLATFORM_DIAG(("ftpd_msgaccept called"));
struct ftpd_msgstate *fsm;
(void) err; /* suppress unused warning */
(void) arg;
/* Allocate memory for the structure that holds the state of the
connection. */

3
test-in-docker/src/main.c

@ -132,6 +132,9 @@ int main(size_t argc, char **argv) {
FATFS fs;
unsigned char *buf[4096];
(void) argc; /* suppress unused warning */
(void) argv;
{
FRESULT r = f_mount(&fs, "", 1);
printf("f_mount returns %d\n", r);

12
vfs.c

@ -39,6 +39,7 @@ FIL guard_for_the_whole_fs;
int vfs_read (void* buffer, int dummy, int len, vfs_file_t* file) {
unsigned int bytesread;
(void) dummy; /* suppress unused warning */
FRESULT r = f_read(file, buffer, len, &bytesread);
if (r != FR_OK) return 0;
return bytesread;
@ -61,6 +62,7 @@ int vfs_stat(vfs_t* vfs, const char* filename, vfs_stat_t* st) {
#if _USE_LFN
f.lfname = NULL;
#endif
(void) vfs; /* suppress unused warning */
if (FR_OK != f_stat(filename, &f)) {
return 1;
}
@ -88,6 +90,8 @@ void vfs_close(vfs_t* vfs) {
int vfs_write (void* buffer, int dummy, int len, vfs_file_t* file) {
unsigned int byteswritten;
(void) dummy; /* suppress unused warning */
FRESULT r = f_write(file, buffer, len, &byteswritten);
if (r != FR_OK) return 0;
return byteswritten;
@ -100,6 +104,8 @@ vfs_t* vfs_openfs() {
vfs_file_t* vfs_open(vfs_t* vfs, const char* filename, const char* mode) {
vfs_file_t *f = malloc(sizeof(vfs_file_t));
BYTE flags = 0;
(void) vfs; /* suppress unused warning */
while (*mode != '\0') {
if (*mode == 'r') flags |= FA_READ;
if (*mode == 'w') flags |= FA_WRITE | FA_CREATE_ALWAYS;
@ -116,6 +122,10 @@ vfs_file_t* vfs_open(vfs_t* vfs, const char* filename, const char* mode) {
char* vfs_getcwd(vfs_t* vfs, void* dummy1, int dummy2) {
char* cwd = malloc(255);
FRESULT r = f_getcwd(cwd, 255);
(void) dummy1; /* suppress unused warning */
(void) dummy2;
(void) vfs;
if (r != FR_OK) {
free(cwd);
return NULL;
@ -126,6 +136,7 @@ char* vfs_getcwd(vfs_t* vfs, void* dummy1, int dummy2) {
vfs_dir_t* vfs_opendir(vfs_t* vfs, const char* path) {
vfs_dir_t* dir = malloc(sizeof *dir);
FRESULT r = f_opendir(dir, path);
(void) vfs; /* suppress unused warning */
if (FR_OK != r) {
free(dir);
return NULL;
@ -148,5 +159,6 @@ struct tm dummy = {
.tm_min = 0
};
struct tm* gmtime(const time_t* c_t) {
(void) c_t;
return &dummy;
}

Loading…
Cancel
Save