Skip to content

Commit

Permalink
selftests/bpf: Fix broken build where char is unsigned
Browse files Browse the repository at this point in the history
There are architectures where char is not signed. If so, the following
error is triggered:

  | xdp_hw_metadata.c:435:42: error: result of comparison of constant -1 \
  |   with expression of type 'char' is always true \
  |   [-Werror,-Wtautological-constant-out-of-range-compare]
  |   435 |         while ((opt = getopt(argc, argv, "mh")) != -1) {
  |       |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~
  | 1 error generated.

Correct by changing the char to int.

Fixes: bb6a888 ("selftests/bpf: Add options and frags to xdp_hw_metadata")
Signed-off-by: Björn Töpel <[email protected]>
Acked-by: Larysa Zaremba <[email protected]>
Tested-by: Anders Roxell <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
bjorn-rivos authored and Alexei Starovoitov committed Nov 2, 2023
1 parent 94e88b8 commit d84b139
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/xdp_hw_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static void print_usage(void)

static void read_args(int argc, char *argv[])
{
char opt;
int opt;

while ((opt = getopt(argc, argv, "mh")) != -1) {
switch (opt) {
Expand Down

0 comments on commit d84b139

Please sign in to comment.