Skip to contentSkip to conversation

tools: perf: fix augmented syscall format warning

PATCH Applied Cengiz Can 3 participants 3 messages Jan 13, 2020 – Jan 20, 2020 perf events

lore
Share & tools
lore

Cengiz Can

author
#0 lore raw

PATCH 1/1 tools: perf: fix augmented syscall format warning

sockaddr related examples given in tools/perf/examples/bpf/augmented_syscalls.c almost always use longs to represent most of their fields.

However, size_t syscall_arg__scnprintf_sockaddr(..) has a scnprintf call that uses "%#x" as format string.

This throws a warning (whenever the syscall argument is unsigned long).

Added l identifier to indicate that the arg->value is an unsigned long.

Not sure about the complications of this with x86 though.

---
 tools/perf/trace/beauty/sockaddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/trace/beauty/sockaddr.c +1 -1
index 173c8f760763..e0c13e6a5788 100644
@@ -72,5 +72,5 @@ size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg
 	if (arg->augmented.args)
 		return syscall_arg__scnprintf_augmented_sockaddr(arg, bf, size);
 
-	return scnprintf(bf, size, "%#x", arg->val);
+	return scnprintf(bf, size, "%#lx", arg->val);
 }

--
2.24.1

#1 lore raw

Em Mon, Jan 13, 2020 at 08:44:39PM +0300, Cengiz Can escreveu:

Quoted 4 lines

sockaddr related examples given in tools/perf/examples/bpf/augmented_syscalls.c almost always use longs to represent most of their fields.

Quoted 8 lines

However, size_t syscall_arg__scnprintf_sockaddr(..) has a scnprintf call that uses "%#x" as format string.

This throws a warning (whenever the syscall argument is unsigned long).

Added l identifier to indicate that the arg->value is an unsigned long.

arg->val is a 'unsigned long', so yeah, we can make that lx to make it work in more places,

In fact it should be fallbacking to this, that does just like you did here:

size_t syscall_arg__scnprintf_hex(char *bf, size_t size, struct syscall_arg *arg)

{
        return scnprintf(bf, size, "%#lx", arg->val);
}

It is in tools/perf/builtin-trace.c

Thanks,

- Arnaldo

Quoted 21 lines

Not sure about the complications of this with x86 though.

---
 tools/perf/trace/beauty/sockaddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/trace/beauty/sockaddr.c +1 -2
index 173c8f760763..e0c13e6a5788 100644
@@ -72,5 +72,5 @@ size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg
 	if (arg->augmented.args)
 		return syscall_arg__scnprintf_augmented_sockaddr(arg, bf, size);
 
-	return scnprintf(bf, size, "%#x", arg->val);
+	return scnprintf(bf, size, "%#lx", arg->val);
 }
--

2.24.1

Signature · 1 line
- Arnaldo
merge bot Applied
#2 lore raw

[tip: perf/core] perf beauty sockaddr: Fix augmented syscall format warning

In reply to Cengiz Can
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     49e0b6f4e95aa3ade8f512c50d1ccc113fe917b4
Gitweb:        https://git.kernel.org/tip/49e0b6f4e95aa3ade8f512c50d1ccc113fe917b4
Author:        Cengiz Can <[email protected]>
AuthorDate:    Mon, 13 Jan 2020 20:44:39 +03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Tue, 14 Jan 2020 12:42:26 -03:00

perf beauty sockaddr: Fix augmented syscall format warning

The sockaddr related examples given in tools/perf/examples/bpf/augmented_syscalls.c almost always use longs to represent most of their fields.

However, size_t syscall_arg__scnprintf_sockaddr(..) has a scnprintf call that uses "%#x" as format string.

This throws a warning (whenever the syscall argument is unsigned long).

Added l identifier to indicate that the arg->value is an unsigned long.

Not sure about the complications of this with x86 though.

---
 tools/perf/trace/beauty/sockaddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/trace/beauty/sockaddr.c +1 -1
index 173c8f7..e0c13e6 100644
@@ -72,5 +72,5 @@ size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg
 	if (arg->augmented.args)
 		return syscall_arg__scnprintf_augmented_sockaddr(arg, bf, size);
 
-	return scnprintf(bf, size, "%#x", arg->val);
+	return scnprintf(bf, size, "%#lx", arg->val);
 }