[OLPC Networking] [PATCH 1/5] libertas: avoid a few gcc warnings

Arnd Bergmann arnd at arndb.de
Tue Jul 4 23:10:30 EDT 2006


Use min_t instead of min to avoid compiler warnings.

Signed-off-by: Arnd Bergmann <arnd at arndb.de>

===================================================================
--- libertas.orig/drivers/net/wireless/libertas/wlan_join.c	2006-07-05 01:10:24.000000000 +0200
+++ libertas/drivers/net/wireless/libertas/wlan_join.c	2006-07-05 01:34:36.000000000 +0200
@@ -63,7 +63,7 @@
 	int i;
 
 	memset(&tmp, 0, sizeof(tmp));
-	memcpy(&tmp, rate1, min(rate1_size, sizeof(tmp)));
+	memcpy(&tmp, rate1, min_t(size_t, rate1_size, sizeof(tmp)));
 	memset(rate1, 0, rate1_size);
 
 	/* Mask the top bit of the original values */
@@ -860,7 +860,7 @@
 		goto done;
 	}
 
-	rates->Header.Len = min(strlen(rates->Rates), WLAN_SUPPORTED_RATES);
+	rates->Header.Len = min_t(size_t, strlen(rates->Rates), WLAN_SUPPORTED_RATES);
 	Adapter->CurBssParams.NumOfRates = rates->Header.Len;
 
 	pos += sizeof(rates->Header) + rates->Header.Len;
@@ -884,7 +884,7 @@
 
 	/* Copy the infra. association rates into Current BSS state structure */
 	memcpy(&Adapter->CurBssParams.DataRates, &rates->Rates,
-	       min(sizeof(Adapter->CurBssParams.DataRates), rates->Header.Len));
+	       min_t(size_t, sizeof(Adapter->CurBssParams.DataRates), rates->Header.Len));
 
 	PRINTM(INFO, "ASSOC_CMD: rates->Header.Len = %d\n", rates->Header.Len);
 
Index: libertas/drivers/net/wireless/libertas/wlan_scan.c
===================================================================
--- libertas.orig/drivers/net/wireless/libertas/wlan_scan.c	2006-07-05 01:10:24.000000000 +0200
+++ libertas/drivers/net/wireless/libertas/wlan_scan.c	2006-07-05 01:32:52.000000000 +0200
@@ -1233,7 +1233,7 @@
 
 			if (!memcmp(pIe->oui, oui01, sizeof(oui01))) {
 				pwpa_supplicant->Wpa_ie_len
-				    = min(elemLen + IE_ID_LEN_FIELDS_BYTES,
+				    = min_t(size_t, elemLen + IE_ID_LEN_FIELDS_BYTES,
 					  sizeof(pwpa_supplicant->Wpa_ie));
 				memcpy(pwpa_supplicant->Wpa_ie,
 				       pCurrentPtr,
@@ -1245,7 +1245,7 @@
 		case WPA2_IE:
 			pIe = (struct IE_WPA *)pCurrentPtr;
 			pwpa2_supplicant->Wpa_ie_len
-			    = min(elemLen + IE_ID_LEN_FIELDS_BYTES,
+			    = min_t(size_t, elemLen + IE_ID_LEN_FIELDS_BYTES,
 				  sizeof(pwpa2_supplicant->Wpa_ie));
 			memcpy(pwpa2_supplicant->Wpa_ie,
 			       pCurrentPtr, pwpa2_supplicant->Wpa_ie_len);
@@ -2069,7 +2069,7 @@
 
 	if (copy_from_user(&scanReq,
 			   wrq->u.data.pointer,
-			   min(wrq->u.data.length, sizeof(scanReq))) != 0) {
+			   min_t(size_t, wrq->u.data.length, sizeof(scanReq))) != 0) {
 		/* copy_from_user failed  */
 		PRINTM(INFO, "SetUserScan: copy from user failed\n");
 		retcode = -EFAULT;
Index: libertas/drivers/net/wireless/libertas/wlan_wext.c
===================================================================
--- libertas.orig/drivers/net/wireless/libertas/wlan_wext.c	2006-07-05 01:10:24.000000000 +0200
+++ libertas/drivers/net/wireless/libertas/wlan_wext.c	2006-07-05 01:31:58.000000000 +0200
@@ -1669,7 +1669,7 @@
 	memset(rates, 0, sizeof(rates));
 	range->num_bitrates = get_active_data_rates(Adapter, rates);
 
-	for (i = 0; i < min(range->num_bitrates, IW_MAX_BITRATES) && rates[i];
+	for (i = 0; i < min_t(__u8, range->num_bitrates, IW_MAX_BITRATES) && rates[i];
 	     i++) {
 		range->bitrate[i] = (rates[i] & 0x7f) * 500000;
 	}
@@ -2587,7 +2587,7 @@
 	if (wrq->u.data.length) {
 		if (copy_from_user
 		    (data, wrq->u.data.pointer,
-		     min(wrq->u.data.length, 4) * sizeof(int))) {
+		     min_t(size_t, wrq->u.data.length, 4) * sizeof(int))) {
 			PRINTM(INFO, "Copy from user failed\n");
 			return -EFAULT;
 		}
@@ -3437,7 +3437,7 @@
 	} else {
 		if (copy_to_user(wrq->u.data.pointer,
 				 &tsfVal,
-				 min(wrq->u.data.length,
+				 min_t(size_t, wrq->u.data.length,
 				     sizeof(tsfVal))) != 0) {
 
 			PRINTM(INFO, "IOCTL: Get TSF; Copy to user failed\n");
@@ -3675,7 +3675,7 @@
 	memset(&sp, 0, sizeof(sp));
 
 	if (copy_from_user(&sp, wrq->u.data.pointer,
-			   min(sizeof(sp), wrq->u.data.length))) {
+			   min_t(size_t, sizeof(sp), wrq->u.data.length))) {
 		PRINTM(INFO, "Copy from user failed\n");
 		return -EFAULT;
 	}
@@ -3750,7 +3750,7 @@
 
 	memset(buf, 0, sizeof(buf));
 
-	if (copy_from_user(buf, wrq->u.data.pointer, min(sizeof(buf),
+	if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf),
 							 wrq->u.data.length))) {
 		PRINTM(INFO, "Copy from user failed\n");
 		return -EFAULT;
@@ -3812,7 +3812,7 @@
 
 	memset(buf, 0, sizeof(buf));
 
-	if (copy_from_user(buf, wrq->u.data.pointer, min(sizeof(buf),
+	if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf),
 							 wrq->u.data.length))) {
 		PRINTM(INFO, "Copy from user failed\n");
 		return -EFAULT;
@@ -4102,7 +4102,7 @@
 		case WLAN_SET_ATIM_WINDOW:
 			Adapter->AtimWindow =
 			    *((int *)(wrq->u.name + SUBCMD_OFFSET));
-			Adapter->AtimWindow = min(Adapter->AtimWindow, 50);
+			Adapter->AtimWindow = min_t(__u16, Adapter->AtimWindow, 50);
 			break;
 		case WLANSETBCNAVG:
 			Adapter->bcn_avg_factor =
@@ -5161,7 +5161,7 @@
 
 	/* To make the driver backward compatible with WPA supplicant v0.2.4 */
 	if (dwrq->length == 32)	/* check with WPA supplicant buffer size */
-		dwrq->length = min(Adapter->CurBssParams.ssid.SsidLength,
+		dwrq->length = min_t(size_t, Adapter->CurBssParams.ssid.SsidLength,
 				   IW_ESSID_MAX_SIZE);
 	else
 		dwrq->length = Adapter->CurBssParams.ssid.SsidLength + 1;

--



More information about the Networking mailing list