diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2023-01-26 14:53:47 +0100 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2023-01-27 12:01:20 +0100 |
| commit | c84e51870940311bb6ec67d8b192da1ce32cba8f (patch) | |
| tree | 5d1c214da53ca54b575e0b9e7c66d3c2422b1751 /lib/vty.c | |
| parent | 0f9de11a11644b77cc60d6ff6ac4519d2e5c29e1 (diff) | |
*: no-warn pragmas for non-const format strings
We do use non-constant/literal format strings in a few places for more
or less valid reasons; put `ignored "-Wformat-nonliteral"` around those
so we can have the warning enabled for everywhere else.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/vty.c')
| -rw-r--r-- | lib/vty.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -343,6 +343,15 @@ void vty_hello(struct vty *vty) vty_out(vty, "%s", host.motd); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +/* prompt formatting has a %s in the cmd_node prompt string. + * + * Also for some reason GCC emits the warning on the end of the function + * (optimization maybe?) rather than on the vty_out line, so this pragma + * wraps the entire function rather than just the vty_out line. + */ + /* Put out prompt and wait input from user. */ static void vty_prompt(struct vty *vty) { @@ -350,6 +359,7 @@ static void vty_prompt(struct vty *vty) vty_out(vty, cmd_prompt(vty->node), cmd_hostname_get()); } } +#pragma GCC diagnostic pop /* Send WILL TELOPT_ECHO to remote server. */ static void vty_will_echo(struct vty *vty) @@ -464,8 +474,12 @@ static int vty_command(struct vty *vty, char *buf) vty->address); /* format the prompt */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + /* prompt formatting has a %s in the cmd_node prompt string */ snprintf(prompt_str, sizeof(prompt_str), cmd_prompt(vty->node), vty_str); +#pragma GCC diagnostic pop /* now log the command */ zlog_notice("%s%s", prompt_str, buf); |
