Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning under GCC #17

Open
stawiski opened this issue Nov 20, 2021 · 1 comment
Open

Warning under GCC #17

stawiski opened this issue Nov 20, 2021 · 1 comment

Comments

@stawiski
Copy link
Contributor

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 ?

@spacehuhn
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants