diff options
author | Dan Carpenter <error27@gmail.com> | 2010-05-07 21:47:16 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-11 13:42:38 -0700 |
commit | db315014ff8148e73d10e927d14c962d2cabd370 (patch) | |
tree | 9aa029af1e74a19e2544d37a097aff4cb5cc61f5 /drivers/staging | |
parent | 56c341d7af78f6766238725f79a1773aca942795 (diff) |
Staging: batman-adv: cleanup: change test for end of array
The code here is testing to see if "i" is passed the end of the array.
The original code works probably, but it's not the cleanest way.
Andrew Lunn suggested that I also remove all the hard coded references
to 256 so I have done that as well.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/batman-adv/device.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/staging/batman-adv/device.c b/drivers/staging/batman-adv/device.c index c82a5afe8fa8..fbfe234104d2 100644 --- a/drivers/staging/batman-adv/device.c +++ b/drivers/staging/batman-adv/device.c @@ -44,10 +44,7 @@ static struct device_client *device_client_hash[256]; void bat_device_init(void) { - int i; - - for (i = 0; i < 256; i++) - device_client_hash[i] = NULL; + memset(device_client_hash, 0, sizeof(device_client_hash)); } int bat_device_setup(void) @@ -103,15 +100,15 @@ int bat_device_open(struct inode *inode, struct file *file) if (!device_client) return -ENOMEM; - for (i = 0; i < 256; i++) { + for (i = 0; i < ARRAY_SIZE(device_client_hash); i++) { if (!device_client_hash[i]) { device_client_hash[i] = device_client; break; } } - if (device_client_hash[i] != device_client) { - printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached \n"); + if (i == ARRAY_SIZE(device_client_hash)) { + printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n"); kfree(device_client); return -EXFULL; } |