diff mbox series

[bpf-next] libbpf: Ignore warnings about "inefficient alignment"

Message ID 20230315171550.1551603-1-deso@posteo.net (mailing list archive)
State Accepted
Commit 6cb9430be1471d631e1b6b138e6d26657a9caa81
Delegated to: BPF
Headers show
Series [bpf-next] libbpf: Ignore warnings about "inefficient alignment" | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 20 this patch: 20
netdev/cc_maintainers fail 1 blamed authors not CCed: michalgr@meta.com; 9 maintainers not CCed: song@kernel.org michalgr@meta.com sdf@google.com haoluo@google.com yhs@fb.com john.fastabend@gmail.com kpsingh@kernel.org jolsa@kernel.org martin.lau@linux.dev
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 20 this patch: 20
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain }}
bpf/vmtest-bpf-next-VM_Test-2 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-5 fail Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-8 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-9 success Logs for set-matrix

Commit Message

Daniel Müller March 15, 2023, 5:15 p.m. UTC
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.

Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Link: https://lore.kernel.org/bpf/CA+G9fYtBnwxAWXi2+GyNByApxnf_DtP1-6+_zOKAdJKnJBexjg@mail.gmail.com/
Fixes: 1eebcb60633f ("libbpf: Implement basic zip archive parsing support")
Signed-off-by: Daniel Müller <deso@posteo.net>
---
 tools/lib/bpf/zip.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Daniel Müller March 15, 2023, 9:30 p.m. UTC | #1
For what it's worth, I was unable to reproduce the original issue, locally and
in CI. So this is a best guess at a fix based on the suggestion provided in the
linked report.

Thanks,
Daniel

On Wed, Mar 15, 2023 at 05:15:50PM +0000, Daniel Müller wrote:
> 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.
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> Link: https://lore.kernel.org/bpf/CA+G9fYtBnwxAWXi2+GyNByApxnf_DtP1-6+_zOKAdJKnJBexjg@mail.gmail.com/
> Fixes: 1eebcb60633f ("libbpf: Implement basic zip archive parsing support")
> Signed-off-by: Daniel Müller <deso@posteo.net>
> ---
>  tools/lib/bpf/zip.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tools/lib/bpf/zip.c b/tools/lib/bpf/zip.c
> index f561aa..3f26d62 100644
> --- a/tools/lib/bpf/zip.c
> +++ b/tools/lib/bpf/zip.c
> @@ -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
> @@ -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;
> -- 
> 2.34.1
>
patchwork-bot+netdevbpf@kernel.org March 16, 2023, 5:30 p.m. UTC | #2
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Wed, 15 Mar 2023 17:15:50 +0000 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [bpf-next] libbpf: Ignore warnings about "inefficient alignment"
    https://git.kernel.org/bpf/bpf-next/c/6cb9430be147

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/lib/bpf/zip.c b/tools/lib/bpf/zip.c
index f561aa..3f26d62 100644
--- a/tools/lib/bpf/zip.c
+++ b/tools/lib/bpf/zip.c
@@ -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
@@ -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;