From: Tom Stellard <tstellar@redhat.com>
To: systemtap@sourceware.org
Subject: [PATCH 7/8] Fix -Wformat-nonliteral and -Wformat warnings with clang
Date: Mon, 30 Nov 2020 19:58:40 +0000 [thread overview]
Message-ID: <20201130195841.26142-8-tstellar@redhat.com> (raw)
In-Reply-To: <20201130195841.26142-1-tstellar@redhat.com>
---
stapbpf/stapbpf.cxx | 4 ++--
staprun/common.c | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/stapbpf/stapbpf.cxx b/stapbpf/stapbpf.cxx
index 933164851..7b614015a 100644
--- a/stapbpf/stapbpf.cxx
+++ b/stapbpf/stapbpf.cxx
@@ -246,7 +246,7 @@ static std::vector<uprobe_data> 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)
@@ -773,7 +773,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<char *>(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 6a603cd2b..6f1b3d683 100644
--- a/staprun/common.c
+++ b/staprun/common.c
@@ -683,6 +683,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;
@@ -712,7 +713,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);
}
--
2.26.2
next prev parent reply other threads:[~2020-11-30 19:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 19:58 Clang build fixes Tom Stellard
2020-11-30 19:58 ` [PATCH 1/8] Fix a few class/struct mixups Tom Stellard
2020-11-30 19:58 ` [PATCH 2/8] util: Use abs() instead of labs() Tom Stellard
2020-11-30 19:58 ` [PATCH 3/8] Add some override specifiers where missing Tom Stellard
2020-11-30 19:58 ` [PATCH 4/8] Add missing copy constructors to set1_ref and set1_const_ref Tom Stellard
2020-11-30 19:58 ` [PATCH 5/8] set2: Return this from assignment operator Tom Stellard
2020-11-30 19:58 ` [PATCH 6/8] Fix -Woverloaded-virtual warnings when building with clang Tom Stellard
2020-11-30 19:58 ` Tom Stellard [this message]
2020-11-30 19:58 ` [PATCH 8/8] dtrace: Use -o option to specify output file for CPP Tom Stellard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201130195841.26142-8-tstellar@redhat.com \
--to=tstellar@redhat.com \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).