selftests/bpf: Fix broken build where char is unsigned
authorBjörn Töpel <bjorn@rivosinc.com>
Thu, 2 Nov 2023 10:35:37 +0000 (11:35 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 2 Nov 2023 14:57:21 +0000 (07:57 -0700)
commitd84b139f53e8fa8048f16814c6b2a53d7bc15c3d
tree7a2fe59a181f0c1ac1070327cc757bbbfbbdeb51
parent94e88b8a3e50d3e60c3ba6a5c316729587595210
selftests/bpf: Fix broken build where char is unsigned

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: bb6a88885fde ("selftests/bpf: Add options and frags to xdp_hw_metadata")
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Acked-by: Larysa Zaremba <larysa.zaremba@intel.com>
Tested-by: Anders Roxell <anders.roxell@linaro.org>
Link: https://lore.kernel.org/r/20231102103537.247336-1-bjorn@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/xdp_hw_metadata.c