staging: replace open-coded ARRAY_SIZEs
authorJim Cromie <jim.cromie@gmail.com>
Tue, 10 Apr 2012 22:06:41 +0000 (16:06 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Apr 2012 22:25:55 +0000 (15:25 -0700)
spatch http://coccinelle.lip6.fr/rules/array.cocci did these.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/bcm/DDRInit.c
drivers/staging/media/as102/as102_usb_drv.c
drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
drivers/staging/rtl8192e/rtllib_wx.c
drivers/staging/rtl8192u/r8192U_wx.c
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
drivers/staging/vt6655/wpa.c
drivers/staging/vt6656/wpa.c

index 1c7db81a1ee8554e14581ce68f27f6e5fcea3d0e..2b46f4d4ef0eb4cf8de126411f54a284aa3ffab7 100644 (file)
@@ -1115,20 +1115,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
            {
                case DDR_80_MHZ:
                                psDDRSetting = asT3LP_DDRSetting80MHz;
-                RegCount = (sizeof(asT3LP_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+                RegCount = ARRAY_SIZE(asT3LP_DDRSetting80MHz);
                                RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
                 psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
                        break;
                    case DDR_100_MHZ:
                                psDDRSetting = asT3LP_DDRSetting100MHz;
-                           RegCount = (sizeof(asT3LP_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+                           RegCount = ARRAY_SIZE(asT3LP_DDRSetting100MHz);
                                RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
                 psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
                            break;
                     case DDR_133_MHZ:
                                bOverrideSelfRefresh = TRUE;
                                psDDRSetting = asT3LP_DDRSetting133MHz;
-                           RegCount = (sizeof(asT3LP_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+                           RegCount = ARRAY_SIZE(asT3LP_DDRSetting133MHz);
                                RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
                        psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
                                break;
@@ -1146,20 +1146,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
            {
                case DDR_80_MHZ:
                                psDDRSetting = asT3LPB_DDRSetting80MHz;
-                RegCount=(sizeof(asT3LPB_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+                RegCount=ARRAY_SIZE(asT3LPB_DDRSetting80MHz);
                                RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
                 psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
                        break;
                    case DDR_100_MHZ:
                                psDDRSetting = asT3LPB_DDRSetting100MHz;
-                           RegCount = (sizeof(asT3LPB_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+                           RegCount = ARRAY_SIZE(asT3LPB_DDRSetting100MHz);
                                RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
                 psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
                            break;
                     case DDR_133_MHZ:
                                bOverrideSelfRefresh = TRUE;
                                psDDRSetting = asT3LPB_DDRSetting133MHz;
-                           RegCount = (sizeof(asT3LPB_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+                           RegCount = ARRAY_SIZE(asT3LPB_DDRSetting133MHz);
                                RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
                        psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
                                break;
@@ -1167,7 +1167,7 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
                        case DDR_160_MHZ:
                                        bOverrideSelfRefresh = TRUE;
                                        psDDRSetting = asT3LPB_DDRSetting160MHz;
-                                       RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SET_NODE);
+                                       RegCount = ARRAY_SIZE(asT3LPB_DDRSetting160MHz);
                                        RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
                                        psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
 
@@ -1181,19 +1181,19 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
            {
                case DDR_80_MHZ:
                                psDDRSetting = asT3_DDRSetting80MHz;
-                RegCount = (sizeof(asT3_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+                RegCount = ARRAY_SIZE(asT3_DDRSetting80MHz);
                                RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
                 psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
                        break;
                    case DDR_100_MHZ:
                                psDDRSetting = asT3_DDRSetting100MHz;
-                           RegCount = (sizeof(asT3_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+                           RegCount = ARRAY_SIZE(asT3_DDRSetting100MHz);
                                RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
                 psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
                            break;
                     case DDR_133_MHZ:
                                psDDRSetting = asT3_DDRSetting133MHz;
-                           RegCount = (sizeof(asT3_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+                           RegCount = ARRAY_SIZE(asT3_DDRSetting133MHz);
                                RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
                        psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
                                break;
@@ -1207,20 +1207,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
                    {
                        case DDR_80_MHZ:
                                        psDDRSetting = asT3B_DDRSetting80MHz;
-                    RegCount = (sizeof(asT3B_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+                    RegCount = ARRAY_SIZE(asT3B_DDRSetting80MHz);
                     RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
                     psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
                                break;
                        case DDR_100_MHZ:
                                        psDDRSetting = asT3B_DDRSetting100MHz;
-                               RegCount = (sizeof(asT3B_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+                               RegCount = ARRAY_SIZE(asT3B_DDRSetting100MHz);
                     RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
                     psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
                                break;
                        case DDR_133_MHZ:
                                        bOverrideSelfRefresh = TRUE;
                                        psDDRSetting = asT3B_DDRSetting133MHz;
-                               RegCount = (sizeof(asT3B_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+                               RegCount = ARRAY_SIZE(asT3B_DDRSetting133MHz);
                        RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
                            psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
                                        break;
index 0f6bfe7eccba344a71868db8c6a0a6261cd31a06..36150e5c62de9deebbb8101137a3cd19c8007466 100644 (file)
@@ -367,7 +367,7 @@ static int as102_usb_probe(struct usb_interface *intf,
        ENTER();
 
        /* This should never actually happen */
-       if ((sizeof(as102_usb_id_table) / sizeof(struct usb_device_id)) !=
+       if (ARRAY_SIZE(as102_usb_id_table) !=
            (sizeof(as102_device_names) / sizeof(const char *))) {
                pr_err("Device names table invalid size");
                return -EINVAL;
@@ -380,8 +380,7 @@ static int as102_usb_probe(struct usb_interface *intf,
        }
 
        /* Assign the user-friendly device name */
-       for (i = 0; i < (sizeof(as102_usb_id_table) /
-                        sizeof(struct usb_device_id)); i++) {
+       for (i = 0; i < ARRAY_SIZE(as102_usb_id_table); i++) {
                if (id == &as102_usb_id_table[i]) {
                        as102_dev->name = as102_device_names[i];
                        as102_dev->elna_cfg = as102_elna_cfg[i];
index 4e93669210affa2d1f9c1501742198e3453eee5c..778d7baf8e08eb67d079a3ab34a265e1cdc70a3c 100644 (file)
@@ -1322,9 +1322,9 @@ static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
 
 struct iw_handler_def  r8192_wx_handlers_def = {
        .standard = r8192_wx_handlers,
-       .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler),
+       .num_standard = ARRAY_SIZE(r8192_wx_handlers),
        .private = r8192_private_handler,
-       .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler),
+       .num_private = ARRAY_SIZE(r8192_private_handler),
        .num_private_args = sizeof(r8192_private_args) /
                            sizeof(struct iw_priv_args),
        .get_wireless_stats = r8192_get_wireless_stats,
index c27ff7edbaf285d9b1d3889c82428db189009100..e5fe2e89373a8623429c15681c40f013ea9b4399 100644 (file)
@@ -88,7 +88,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
        }
        /* Add the protocol name */
        iwe.cmd = SIOCGIWNAME;
-       for (i = 0; i < (sizeof(rtllib_modes)/sizeof(rtllib_modes[0])); i++) {
+       for (i = 0; i < ARRAY_SIZE(rtllib_modes); i++) {
                if (network->mode&(1<<i)) {
                        sprintf(pname, rtllib_modes[i].mode_string,
                                rtllib_modes[i].mode_size);
index f6408f98ede628cbc800f0178c39c4e710bc3e31..981de9b87d68b98ca9f21e12f2e2a4521315a8a5 100644 (file)
@@ -1211,9 +1211,9 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
 
 struct iw_handler_def  r8192_wx_handlers_def={
        .standard = r8192_wx_handlers,
-       .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler),
+       .num_standard = ARRAY_SIZE(r8192_wx_handlers),
        .private = r8192_private_handler,
-       .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler),
+       .num_private = ARRAY_SIZE(r8192_private_handler),
        .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args),
 #if WIRELESS_EXT >= 17
        .get_wireless_stats = r8192_get_wireless_stats,
index ef35bc29a3faf619b15ff2ce4290c2eebc550f02..299350ce978ddc8bf669b4e08bba3bcac060636b 100644 (file)
@@ -2389,10 +2389,10 @@ static struct iw_statistics *r871x_get_wireless_stats(struct net_device *dev)
 
 struct iw_handler_def r871x_handlers_def = {
        .standard = r8711_handlers,
-       .num_standard = sizeof(r8711_handlers) / sizeof(iw_handler),
+       .num_standard = ARRAY_SIZE(r8711_handlers),
        .private = r8711_private_handler,
        .private_args = (struct iw_priv_args *)r8711_private_args,
-       .num_private = sizeof(r8711_private_handler) / sizeof(iw_handler),
+       .num_private = ARRAY_SIZE(r8711_private_handler),
        .num_private_args = sizeof(r8711_private_args) /
                            sizeof(struct iw_priv_args),
        .get_wireless_stats = r871x_get_wireless_stats
index 61ac46fa505e9f1bbe6105a4b5c93bf9a4c38884..0afb9fe0379a441e297692d260db6c6da9781c15 100644 (file)
@@ -148,7 +148,7 @@ WPA_ParseRSN (
         {
             j = 0;
             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d, sizeof(pBSSList->abyPKType): %zu\n", pRSN->wPKCount, sizeof(pBSSList->abyPKType));
-            for(i = 0; (i < pRSN->wPKCount) && (j < sizeof(pBSSList->abyPKType)/sizeof(unsigned char)); i++) {
+            for(i = 0; (i < pRSN->wPKCount) && (j < ARRAY_SIZE(pBSSList->abyPKType)); i++) {
                 if(pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i)
                     if ( !memcmp(pRSN->PKSList[i].abyOUI, abyOUI00, 4))
                         pBSSList->abyPKType[j++] = WPA_NONE;
@@ -180,7 +180,7 @@ WPA_ParseRSN (
             j = 0;
             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d, sizeof(pBSSList->abyAuthType): %zu\n",
                           pIE_RSN_Auth->wAuthCount, sizeof(pBSSList->abyAuthType));
-            for(i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < sizeof(pBSSList->abyAuthType)/sizeof(unsigned char)); i++) {
+            for(i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < ARRAY_SIZE(pBSSList->abyAuthType)); i++) {
                 if(pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i)
                     if ( !memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4))
                         pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X;
index 7dde3d6941ab1bd7d85949cdade860b4d2439bbf..b16d4ddc117bc995f1c5a77053596e010cfdde7b 100644 (file)
@@ -149,7 +149,7 @@ WPA_ParseRSN(
             j = 0;
             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d, sizeof(pBSSList->abyPKType): %zu\n", pRSN->wPKCount, sizeof(pBSSList->abyPKType));
            for (i = 0; (i < pRSN->wPKCount) &&
-                  (j < sizeof(pBSSList->abyPKType)/sizeof(BYTE)); i++) {
+                  (j < ARRAY_SIZE(pBSSList->abyPKType)); i++) {
                 if(pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i)
                     if ( !memcmp(pRSN->PKSList[i].abyOUI, abyOUI00, 4))
                         pBSSList->abyPKType[j++] = WPA_NONE;
@@ -182,7 +182,7 @@ WPA_ParseRSN(
             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d, sizeof(pBSSList->abyAuthType): %zu\n",
                           pIE_RSN_Auth->wAuthCount, sizeof(pBSSList->abyAuthType));
            for (i = 0; (i < pIE_RSN_Auth->wAuthCount) &&
-                  (j < sizeof(pBSSList->abyAuthType)/sizeof(BYTE)); i++) {
+                  (j < ARRAY_SIZE(pBSSList->abyAuthType)); i++) {
                 if(pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i)
                     if ( !memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4))
                         pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X;