public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] batman: cleanup: change test for end of array
@ 2010-03-28 11:47 Dan Carpenter
  2010-03-28 12:20 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-03-28 11:47 UTC (permalink / raw)
  To: kernel-janitors

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.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/staging/batman-adv/device.c b/drivers/staging/batman-adv/device.c
index e7f4421..d09e8cd 100644
--- a/drivers/staging/batman-adv/device.c
+++ b/drivers/staging/batman-adv/device.c
@@ -109,8 +109,8 @@ int bat_device_open(struct inode *inode, struct file *file)
 		}
 	}
 
-	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 = 256) {
+		printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n");
 		kfree(device_client);
 		return -EXFULL;
 	}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] batman: cleanup: change test for end of array
  2010-03-28 11:47 [patch] batman: cleanup: change test for end of array Dan Carpenter
@ 2010-03-28 12:20 ` Andrew Lunn
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2010-03-28 12:20 UTC (permalink / raw)
  To: kernel-janitors

On Sun, Mar 28, 2010 at 02:47:39PM +0300, Dan Carpenter wrote:
> 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.

Even better would be to use ARRAY_SIZE and remove all the hardcoded
256's.

	Andrew

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-28 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-28 11:47 [patch] batman: cleanup: change test for end of array Dan Carpenter
2010-03-28 12:20 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox