[PATCH 3/5] samples/bpf: fix xdpsock_user build error

From: Matteo Croce
Date: Fri May 17 2019 - 20:49:18 EST


Remove duplicate typedef, and use PRIu64 to be both 32 and 64 bit aware.
Fix the following error:

samples/bpf/xdpsock_user.c:52:15: error: conflicting types for âu64â
52 | typedef __u64 u64;
| ^~~
In file included from ./tools/include/linux/compiler.h:87,
from ./tools/include/asm/barrier.h:2,
from samples/bpf/xdpsock_user.c:4:
./tools/include/linux/types.h:30:18: note: previous declaration of âu64â was here
30 | typedef uint64_t u64;
| ^~~
make[2]: *** [scripts/Makefile.host:109: samples/bpf/xdpsock_user.o] Error 1
make[1]: *** [Makefile:1763: samples/bpf/] Error 2

Signed-off-by: Matteo Croce <mcroce@xxxxxxxxxx>
---
samples/bpf/xdpsock_user.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index d08ee1ab7bb4..a4cd42c2f0b0 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -24,6 +24,7 @@
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/types.h>
+#include <inttypes.h>
#include <time.h>
#include <unistd.h>

@@ -49,9 +50,6 @@
#define DEBUG_HEXDUMP 0
#define MAX_SOCKS 8

-typedef __u64 u64;
-typedef __u32 u32;
-
static unsigned long prev_time;

enum benchmark_type {
@@ -243,7 +241,7 @@ static void hex_dump(void *pkt, size_t length, u64 addr)
if (!DEBUG_HEXDUMP)
return;

- sprintf(buf, "addr=%llu", addr);
+ sprintf(buf, "addr=%" PRIu64, addr);
printf("length = %zu\n", length);
printf("%s | ", buf);
while (length-- > 0) {
--
2.21.0