RE: [PATCH 4/7] CCISS: use ARRAY_SIZE without intermediates

From: Miller, Mike (OS Dev)
Date: Thu Jun 15 2006 - 10:37:43 EST




> -----Original Message-----
> From: Helgaas, Bjorn
> Sent: Wednesday, June 14, 2006 6:11 PM
> To: Miller, Mike (OS Dev)
> Cc: ISS StorageDev; linux-kernel@xxxxxxxxxxxxxxx; Andrew Morton
> Subject: [PATCH 4/7] CCISS: use ARRAY_SIZE without intermediates
>
> It's easier to verify loop bounds if the array name is
> mentioned the for() statement that steps through the array.
>
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@xxxxxx>

Acked-by: Mike Miller <mike.miller@xxxxxx>

>
> Index: rc5-mm3/drivers/block/cciss.c
> ===================================================================
> --- rc5-mm3.orig/drivers/block/cciss.c 2006-06-14
> 15:15:28.000000000 -0600
> +++ rc5-mm3/drivers/block/cciss.c 2006-06-14
> 15:16:13.000000000 -0600
> @@ -104,8 +104,6 @@
> };
> MODULE_DEVICE_TABLE(pci, cciss_pci_device_id);
>
> -#define NR_PRODUCTS ARRAY_SIZE(products)
> -
> /* board_id = Subsystem Device ID & Vendor ID
> * product = Marketing Name for the board
> * access = Address of the struct of function pointers @@
> -2831,14 +2829,14 @@
> print_cfg_table(c->cfgtable);
> #endif /* CCISS_DEBUG */
>
> - for(i=0; i<NR_PRODUCTS; i++) {
> + for(i=0; i<ARRAY_SIZE(products); i++) {
> if (board_id == products[i].board_id) {
> c->product_name = products[i].product_name;
> c->access = *(products[i].access);
> break;
> }
> }
> - if (i == NR_PRODUCTS) {
> + if (i == ARRAY_SIZE(products)) {
> printk(KERN_WARNING "cciss: Sorry, I don't know how"
> " to access the Smart Array controller
> %08lx\n",
> (unsigned long)board_id);
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/