From: Jouni Malinen Date: Mon, 25 Feb 2019 00:57:41 +0000 (+0200) Subject: UBSan: Avoid a warning on unsigned integer overflow X-Git-Tag: hostap_2_8~313 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f7bc0681632e153dd69ed651f91941b4ed3ade3;p=thirdparty%2Fhostap.git 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 --- diff --git a/wpa_supplicant/mbo.c b/wpa_supplicant/mbo.c index bd5020a80..d2f145114 100644 --- a/wpa_supplicant/mbo.c +++ b/wpa_supplicant/mbo.c @@ -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; }