Commit 98fd5030 authored by Joel's avatar Joel Committed by yonghong-song

Bcc build fixes for Android (#2142)

* Mark unused parameters as unused

In Android, we are building libbpf with -Wunused-parameter, mark the
parameters in bpf_detach_tracepoint to prevent errors.

Change-Id: I2d0011746af80898e55d456b973a95330ce6be71
Signed-off-by: default avatarJoel Fernandes <joel@joelfernandes.org>

* Avoid void pointer arithmetic

In Android, we build libbpf with -Wpointer-arith, this causes warnings
as below. Avoid void pointer arithmetic to prevent the warning.

external/bcc/src/cc/perf_reader.c:189:26: error: arithmetic on a pointer
to void is a GNU extension [-Werror,-Wpointer-arith] memcpy(reader->buf
+ len, base, e->size - len);                               ~~~~~~~~~~~ ^

Change-Id: If06535459473c78799b38119786a91e74a208895
Signed-off-by: default avatarJoel Fernandes <joel@joelfernandes.org>

* Cast correctly for unsigned long format specifier

In Android, -Wformat gets passed to the compiler causing a warning. Fix
it by casting.

external/bcc/src/cc/libbpf.c:972:58: error: format specifies type
'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned lo
ng long') [-Werror,-Wformat]

Change-Id: I5e70eeff983f20a0b921e81aee7ddbee6d7de2b3
Signed-off-by: default avatarJoel Fernandes <joel@joelfernandes.org>
parent 2ddbc077
......@@ -84,6 +84,8 @@
#define min(x, y) ((x) < (y) ? (x) : (y))
#define UNUSED(expr) do { (void)(expr); } while (0)
struct bpf_helper {
char *name;
char *required_version;
......@@ -979,7 +981,7 @@ int bpf_attach_uprobe(int progfd, enum bpf_probe_attach_type attach_type,
goto error;
}
res = snprintf(buf, sizeof(buf), "%c:%ss/%s %s:0x%lx", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r',
event_type, event_alias, binary_path, offset);
event_type, event_alias, binary_path, (unsigned long)offset);
if (res < 0 || res >= sizeof(buf)) {
fprintf(stderr, "Event alias (%s) too long for buffer\n", event_alias);
goto error;
......@@ -1108,6 +1110,8 @@ int bpf_attach_tracepoint(int progfd, const char *tp_category,
}
int bpf_detach_tracepoint(const char *tp_category, const char *tp_name) {
UNUSED(tp_category);
UNUSED(tp_name);
// Right now, there is nothing to do, but it's a good idea to encourage
// callers to detach anything they attach.
return 0;
......
......@@ -186,7 +186,7 @@ void perf_reader_event_read(struct perf_reader *reader) {
reader->buf = realloc(reader->buf, e->size);
size_t len = sentinel - begin;
memcpy(reader->buf, begin, len);
memcpy(reader->buf + len, base, e->size - len);
memcpy((void *)((unsigned long)reader->buf + len), base, e->size - len);
ptr = reader->buf;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment