Skip to contentSkip to conversation

staging: rtl8192u: Use min_t instead of min

PATCH In review simran singhal 2 participants 2 messages Feb 14, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 5/9 staging: rtl8192u: Use min_t instead of min

Use min_t instead of min function in ieee80211/ieee80211_wx.c fixed warning:
WARNING: min() should probably be min_t(u8, network->ssid_len, 32)

---
 drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +1 -1
index 2481c21..fff2020 100644
@@ -80,7 +80,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
 		iwe.u.data.length = sizeof("<hidden>");
 		start = iwe_stream_add_point(info, start, stop, &iwe, "<hidden>");
 	} else {
-		iwe.u.data.length = min(network->ssid_len, (u8)32);
+		iwe.u.data.length = min_t(u8, network->ssid_len, 32);
 		start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid);
 	}
 	/* Add the protocol name */
Signature · 1 line
2.7.4
#1 lore raw
Quoted 3 lines · simran singhal

Use min_t instead of min function in ieee80211/ieee80211_wx.c fixed warning:
WARNING: min() should probably be min_t(u8, network->ssid_len, 32)

[]

drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c

Quoted 1 line
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +0 -0

[]

drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, · line 83

Quoted 6 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +1 -1
@@ -80,7 +80,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
 		iwe.u.data.length = sizeof("<hidden>");
 		start = iwe_stream_add_point(info, start, stop, &iwe, "<hidden>");
 	} else {
-		iwe.u.data.length = min(network->ssid_len, (u8)32);
+		iwe.u.data.length = min_t(u8, network->ssid_len, 32);

Umm, no. A checkpatch message that says
"probably", is not a reason to do what it says.

It's _maybe_ something that could be investigated.

ssid_len is size_t and u.data.length is u16.
Why should it be truncated to a u8?

It'd be getter to remove the u8 cast altogether.