Skip to contentSkip to conversation

batman: cleanup: change test for end of array

PATCH Superseded Dan Carpenter 2 participants 2 messages Mar 28, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman: 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.

drivers/staging/batman-adv/device.c +2 -2
index e7f4421..d09e8cd 100644
@@ -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;
 	}
#1 lore raw
Quoted 2 lines · Dan Carpenter

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