Skip to content

Build fails with -Werror=discarded-qualifiers in libbpf.c #373

Description

@loverhacking

When building libbpf-bootstrap/examples/c, the build fails while compiling the bootstrap libbpf used by bpftool.

The error is:

libbpf.c: In function ‘resolve_full_path’:
libbpf.c:11359:35: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
11359 | next_path = strchr(s, ':');
| ^
At top level:
cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1: all warnings being treated as errors

The issue appears to be caused by assigning the result of strchr(s, ':') where s is const char *, to a non-const pointer char *next_path;

Changing it to: const char *next_path fixes this compilation error in my environment.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions