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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> Link: https://lore.kernel.org/bpf/CA+G9fYtBnwxAWXi2+GyNByApxnf_DtP1-6+_zOKAdJKnJBexjg@xxxxxxxxxxxxxx/
> Fixes: 1eebcb60633f ("libbpf: Implement basic zip archive parsing support")
> Signed-off-by: Daniel Müller <deso@xxxxxxxxxx>
> ---
>  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
> 



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux