From: Jason Gunthorpe <jgg@xxxxxxxxxxxx> And fix the resulting format string errors. Resolves clang warning -Wformat-nonliteral Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> --- include/ibdiag_common.h | 9 ++++++--- src/ibportstate.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/ibdiag_common.h b/include/ibdiag_common.h index 6e7ec3851bb190..6808ecb5c28763 100644 --- a/include/ibdiag_common.h +++ b/include/ibdiag_common.h @@ -139,7 +139,8 @@ extern int ibdiag_process_opts(int argc, char *const argv[], void *context, const char *usage_args, const char *usage_examples[]); extern void ibdiag_show_usage(void); -extern void ibexit(const char *fn, const char *msg, ...); +extern void ibexit(const char *fn, const char *msg, ...) + __attribute__((format(printf, 2, 3))); /* convert counter values to a float with a unit specifier returned (using * binary prefix) @@ -162,9 +163,11 @@ int resolve_portid_str(char *ca_name, uint8_t ca_port, ib_portid_t * portid, char *addr_str, enum MAD_DEST dest_type, ib_portid_t *sm_id, const struct ibmad_port *srcport); int vsnprint_field(char *buf, size_t n, enum MAD_FIELDS f, int spacing, - const char *format, va_list va_args); + const char *format, va_list va_args) + __attribute__((format(printf, 5, 0))); int snprint_field(char *buf, size_t n, enum MAD_FIELDS f, int spacing, - const char *format, ...); + const char *format, ...) + __attribute__((format(printf, 5, 6))); void dump_portinfo(void *pi, int tabs); /** diff --git a/src/ibportstate.c b/src/ibportstate.c index f733cf8eab2a92..39118d6d3992f7 100644 --- a/src/ibportstate.c +++ b/src/ibportstate.c @@ -444,7 +444,7 @@ int main(int argc, char **argv) port_args[j].set = 1; if (!port_args[j].val) { if (port_op >= 0) - IBEXIT("%s only one of: ", + IBEXIT("%s only one of: " "query, enable, disable, " "reset, down, arm, active, " "can be specified", -- 2.21.0