Commit 623d387
committed
input: align HID adapter slot type with pad_connection_pad_init
GCC on 10.5 PPC warned:
iohidmanager_hid.c:691: warning: comparison between signed and
unsigned
pad_connection_pad_init() at input/connect/joypad_connection.c:397
returns int32_t and can return -1 on allocation failure. Four HID
drivers store that return value in an adapter struct field and use
it for array indexing. Three got the type wrong:
iohidmanager_hid.c : uint32_t slot (warning reported here)
btstack_hid.c : uint32_t slot (same structural mismatch,
silent - no == -1 check at call site)
libusb_hid.c : int slot (compiles clean, but width is
implicit rather than explicit)
wiiusb_hid.c : int32_t slot (correct)
Align all four on int32_t, matching the return type of
pad_connection_pad_init and wiiusb_hid.c's precedent.
Array-indexing call sites (hid->slots[adapter->slot], hid->hats
[adapter->slot][...], etc.) are unaffected - signed and unsigned
integer types index arrays identically through integer promotion
to ptrdiff_t. The only behavioural effect is that slot == -1
checks (iohidmanager_hid.c:691, libusb_hid.c:313) are now signed/
signed comparisons and actually do what they look like they do.
Previously the iohidmanager check "worked" only because the
promotion rules happen to coerce (int)-1 to UINT32_MAX for the
comparison - accidental correctness.1 parent 4af8e56 commit 623d387
3 files changed
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | | - | |
| 684 | + | |
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
0 commit comments