From 2f7bc0681632e153dd69ed651f91941b4ed3ade3 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 25 Feb 2019 02:57:41 +0200 Subject: [PATCH] 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 --- wpa_supplicant/mbo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; } -- 2.47.2