Skip to content

Commit

Permalink
libbpf: Ignore warnings about "inefficient alignment"
Browse files Browse the repository at this point in the history
Some consumers of libbpf compile the code base with different warnings
enabled. In a report for perf, for example, -Wpacked was set which
caused warnings about "inefficient alignment" to be emitted on a subset
of supported architectures.

With this change we silence specifically those warnings, as we intentionally
worked with packed structs.

This is a similar resolution as in b2f10cd ("perf cpumap: Fix alignment
for masks in event encoding").

Fixes: 1eebcb6 ("libbpf: Implement basic zip archive parsing support")
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Signed-off-by: Daniel Müller <deso@posteo.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/bpf/CA+G9fYtBnwxAWXi2+GyNByApxnf_DtP1-6+_zOKAdJKnJBexjg@mail.gmail.com/
Link: https://lore.kernel.org/bpf/20230315171550.1551603-1-deso@posteo.net
  • Loading branch information
Daniel Müller authored and Daniel Borkmann committed Mar 16, 2023
1 parent 226efec commit 6cb9430
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/lib/bpf/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "libbpf_internal.h"
#include "zip.h"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"

/* Specification of ZIP file format can be found here:
* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
* For a high level overview of the structure of a ZIP file see
Expand Down Expand Up @@ -119,6 +123,8 @@ struct local_file_header {
__u16 extra_field_length;
} __attribute__((packed));

#pragma GCC diagnostic pop

struct zip_archive {
void *data;
__u32 size;
Expand Down

0 comments on commit 6cb9430

Please sign in to comment.