From b3a3929751695310b93ff35f41e68775804cee00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Wed, 19 May 2021 16:59:35 -0400 Subject: [PATCH] Fix -Wformat-nonliteral and -Wformat warnings with clang --- stapbpf/stapbpf.cxx | 4 ++-- staprun/common.c | 3 ++- tapsets.cxx | 5 +---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/stapbpf/stapbpf.cxx b/stapbpf/stapbpf.cxx index 59f794718..153186adf 100644 --- a/stapbpf/stapbpf.cxx +++ b/stapbpf/stapbpf.cxx @@ -269,7 +269,7 @@ static std::vector uprobes; // TODO: Move fatal() to bpfinterp.h and replace abort() calls in the interpreter. // TODO: Add warn() option. -static void __attribute__((noreturn)) +static void __attribute__((noreturn)) __attribute__ ((format (printf, 1, 2))) fatal(const char *str, ...) { if (module_name) @@ -796,7 +796,7 @@ kprobe_collect_from_syms(Elf_Data *sym_data, Elf_Data *str_data) if (syms[i].st_name < str_data->d_size) name = static_cast(str_data->d_buf) + syms[i].st_name; else - fatal("symbol %u has invalid string index\n", i); + fatal("symbol %zu has invalid string index\n", i); maybe_collect_kprobe(name, i, syms[i].st_shndx, syms[i].st_value); } } diff --git a/staprun/common.c b/staprun/common.c index 42c18b7d1..e8b542662 100644 --- a/staprun/common.c +++ b/staprun/common.c @@ -679,6 +679,7 @@ int send_request(int type, void *data, int len) static int use_syslog = 0; + __attribute__ ((format (printf, 1, 2))) void eprintf(const char *fmt, ...) { va_list va; @@ -708,7 +709,7 @@ void print_color(const char *type) char *seq = parse_stap_color(type); if (seq != NULL) { eprintf("\033["); - eprintf(seq); + eprintf("%s", seq); eprintf("m\033[K"); free(seq); } diff --git a/tapsets.cxx b/tapsets.cxx index 9f28612b9..86eaf1a65 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -10360,12 +10360,9 @@ kprobe_derived_probe::kprobe_derived_probe (systemtap_session& sess, void kprobe_derived_probe::printsig (ostream& o) const { - bool nest = true; sole_location()->print (o); o << " /* " << " name = " << symbol_name << "*/"; - - if (nest) - printsig_nested (o); + printsig_nested (o); } void kprobe_derived_probe::join_group (systemtap_session& s) -- 2.43.5