summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/printf/glue.c4
-rw-r--r--lib/printf/vfprintf.c6
-rw-r--r--lib/vty.c14
-rw-r--r--lib/yang_translator.c8
-rw-r--r--lib/zlog.c8
5 files changed, 40 insertions, 0 deletions
diff --git a/lib/printf/glue.c b/lib/printf/glue.c
index 6e39c2d9cf..3ac6e2c0ae 100644
--- a/lib/printf/glue.c
+++ b/lib/printf/glue.c
@@ -293,5 +293,9 @@ static ssize_t printfrr_va(struct fbuf *buf, struct printfrr_eargs *ea,
* when allocating a larger buffer in asnprintfrr()
*/
va_copy(ap, *vaf->va);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ /* can't format check this */
return vbprintfrr(buf, vaf->fmt, ap);
+#pragma GCC diagnostic pop
}
diff --git a/lib/printf/vfprintf.c b/lib/printf/vfprintf.c
index 49fa2b718f..cc886834fa 100644
--- a/lib/printf/vfprintf.c
+++ b/lib/printf/vfprintf.c
@@ -504,14 +504,20 @@ reswitch: switch (ch) {
fmt[4] = ch;
fmt[5] = '\0';
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
snprintf(buf, sizeof(buf), fmt, prec, arg);
+#pragma GCC diagnostic pop
} else {
double arg = GETARG(double);
char fmt[5] = "%.*";
fmt[3] = ch;
fmt[4] = '\0';
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
snprintf(buf, sizeof(buf), fmt, prec, arg);
+#pragma GCC diagnostic pop
}
cp = buf;
/* for proper padding */
diff --git a/lib/vty.c b/lib/vty.c
index 352080e580..76d907408c 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -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);
diff --git a/lib/yang_translator.c b/lib/yang_translator.c
index d562e4d29e..67b7f9aa70 100644
--- a/lib/yang_translator.c
+++ b/lib/yang_translator.c
@@ -339,8 +339,12 @@ yang_translate_xpath(const struct yang_translator *translator, int dir,
if (!mapping)
return YANG_TRANSLATE_NOTFOUND;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ /* processing format strings from mapping node... */
n = sscanf(xpath, mapping->xpath_from_fmt, keys[0], keys[1], keys[2],
keys[3]);
+#pragma GCC diagnostic pop
if (n < 0) {
flog_warn(EC_LIB_YANG_TRANSLATION_ERROR,
"%s: sscanf() failed: %s", __func__,
@@ -348,8 +352,12 @@ yang_translate_xpath(const struct yang_translator *translator, int dir,
return YANG_TRANSLATE_FAILURE;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ /* processing format strings from mapping node... */
snprintf(xpath, xpath_len, mapping->xpath_to_fmt, keys[0], keys[1],
keys[2], keys[3]);
+#pragma GCC diagnostic pop
return YANG_TRANSLATE_SUCCESS;
}
diff --git a/lib/zlog.c b/lib/zlog.c
index 6a36a0b123..e08d22b2b9 100644
--- a/lib/zlog.c
+++ b/lib/zlog.c
@@ -743,7 +743,11 @@ const char *zlog_msg_text(struct zlog_msg *msg, size_t *textlen)
fb.outpos_i = 0;
va_copy(args, msg->args);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ /* format-string checking is done further up the chain */
need += vbprintfrr(&fb, msg->fmt, args);
+#pragma GCC diagnostic pop
va_end(args);
msg->textlen = need;
@@ -762,7 +766,11 @@ const char *zlog_msg_text(struct zlog_msg *msg, size_t *textlen)
fb.outpos_i = 0;
va_copy(args, msg->args);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ /* same as above */
vbprintfrr(&fb, msg->fmt, args);
+#pragma GCC diagnostic pop
va_end(args);
bputch(&fb, '\n');