[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [lvm-devel] [PATCH] Use correct array size!



On 15.3.2010 10:03, Zdenek Kabelac wrote:
> On 13.3.2010 01:17, Malahal Naineni wrote:
>> Signed-off-by: Malahal Naineni (malahal us ibm com)
>>
>> diff -r 5d08ba4ae8e8 -r 8db1b9ee17a8 daemons/dmeventd/dmeventd.c
>> --- a/daemons/dmeventd/dmeventd.c	Thu Mar 11 16:05:21 2010 -0800
>> +++ b/daemons/dmeventd/dmeventd.c	Fri Mar 12 16:15:25 2010 -0800
>> @@ -1369,7 +1369,7 @@ static int _handle_request(struct dm_eve
>>  		{ DM_EVENT_CMD_ACTIVE, _active},
>>  	}, *req;
>>  
>> -	for (req = requests; req < requests + sizeof(requests); req++)
>> +	for (req = requests; req < requests + sizeof(requests) / sizeof(requests[0]); req++)
>>  		if (req->cmd == msg->cmd)
>>  			return req->f(message_data);
> 
> 
> NACK
> 
> Moving via pointers - thus you need to check whether pointer passes
> array boundary (just like C++ vector() iterator)
> 
> see the difference:
> for(req = 0; i < sizeof(requests) / sizeof(requests[0]); req++0

Ahh, I've confused myself.

as req is pointer of the same type, pointer arithmetic applies here as well,
so the patch is correct. We need to add number of array elements.

Zdenek


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]