SimpleCLI icon indicating copy to clipboard operation
SimpleCLI copied to clipboard

Warning under GCC

Open stawiski opened this issue 3 years ago • 1 comments

Hi, compiling under GCC for ESP32 (idf version 4.4) produces a warning:

../components/cli/SimpleCLI/src/c/cmd.c: In function 'cmd_parse':
../components/cli/SimpleCLI/src/c/cmd.c:258:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 if (prefix != '-') {
                    ^
../components/cli/SimpleCLI/src/c/cmd.c:264:13: note: here
             case ARG_DEFAULT:

The problem is here:

        switch (a->mode) {
            // Anonym, Template Arg -> value = value
            case ARG_POS:
                if (prefix != '-') {
                    arg_set_value(a, w->str, w->len);
                    break;
                }

            // Default Arg -> value in next word
            case ARG_DEFAULT:

Since case ARG_POS doesn't break by default. Should there be a break in line 262 in SimpleCLI/src/c/cmd.c ?

stawiski avatar Nov 20 '21 12:11 stawiski

If I remember correctly, it's intended to fall through. So that you can create a command with a positional argument and successfully parse both command value and command -arg value.

spacehuhn avatar Nov 20 '21 12:11 spacehuhn