UBSan: Avoid a warning on unsigned integer overflow

wpa_non_pref_chan_cmp() needs to use explicit typecasts to avoid UBSan
warnings for unsigned integer overflows.

mbo.c:298:26: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-02-25 02:57:41 +02:00
parent f3e671591e
commit 2f7bc06816
1 changed files with 3 additions and 3 deletions

View File

@ -293,10 +293,10 @@ static int wpa_non_pref_chan_cmp(const void *_a, const void *_b)
const struct wpa_mbo_non_pref_channel *a = _a, *b = _b;
if (a->oper_class != b->oper_class)
return a->oper_class - b->oper_class;
return (int) a->oper_class - (int) b->oper_class;
if (a->reason != b->reason)
return a->reason - b->reason;
return a->preference - b->preference;
return (int) a->reason - (int) b->reason;
return (int) a->preference - (int) b->preference;
}