gas: fix building tc-bpf.c on s390x
char is unsigned on s390x, so there are a lot of warnings like: gas/config/tc-bpf.c: In function 'get_token': gas/config/tc-bpf.c:900:14: error: comparison is always false due to limited range of data type [-Werror=type-limits] 900 | if (ch == EOF || len > MAX_TOKEN_SZ) | ^~ Change its type to int, like in the other similar code. There is also: gas/config/tc-bpf.c:735:30: error: 'bpf_endianness' may be used uninitialized in this function [-Werror=maybe-uninitialized] 735 | dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]); | ~~~~~~~~~~~^~~~~~~~~~ -Wmaybe-uninitialized doesn't seem to understand the FSM; just initialize bpf_endianness to silence it. Add an assertion to build_bpf_endianness() in order to catch potential bugs.
This commit is contained in:
parent
c3b0a240ea
commit
c981907770
1 changed files with 4 additions and 2 deletions
|
@ -730,6 +730,8 @@ build_bpf_endianness (char *dst, enum bpf_token_type endianness)
|
|||
|| endianness == BPF_LE32
|
||||
|| endianness == BPF_LE64)
|
||||
be = 0;
|
||||
else
|
||||
gas_assert (endianness == BPF_BE16 || endianness == BPF_BE32 || endianness == BPF_BE64);
|
||||
|
||||
bpf_insn = xasprintf ("%s %%%s,%s", be ? "endbe" : "endle",
|
||||
dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]);
|
||||
|
@ -885,7 +887,7 @@ get_token (const char **insn, char *token, size_t *tlen)
|
|||
} while (0)
|
||||
|
||||
const char *str = *insn;
|
||||
char ch, ch2 = 0;
|
||||
int ch, ch2 = 0;
|
||||
enum bpf_token_type ttype = BPF_UNKNOWN;
|
||||
size_t len = 0;
|
||||
const char *expr = NULL;
|
||||
|
@ -1362,7 +1364,7 @@ bpf_pseudoc_to_normal_syntax (const char *str, char **errmsg)
|
|||
} while (0)
|
||||
|
||||
enum bpf_token_type ttype;
|
||||
enum bpf_token_type bpf_endianness,
|
||||
enum bpf_token_type bpf_endianness = BPF_UNKNOWN,
|
||||
bpf_atomic_insn;
|
||||
enum bpf_token_type bpf_jmp_op = BPF_JEQ; /* Arbitrary. */
|
||||
enum bpf_token_type bpf_cast = BPF_CAST_U8; /* Arbitrary. */
|
||||
|
|
Loading…
Add table
Reference in a new issue