Re: [PATCH 2/2] s390: Fix possibly wrong size in strncmp (smsglucv)

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

 



Jesper Juhl <jj@xxxxxxxxxxxxx> writes:

> On Sat, 29 Jan 2011, Stefan Weil wrote:
>
>> This error was reported by cppcheck:
>> drivers/s390/net/smsgiucv.c:63: error: Using sizeof for array given as function argument returns the size of pointer.
>> 
>> Although there is no runtime problem as long as sizeof(u8 *) == 8,
>> this misleading code should get fixed.
>> 
>> Cc: Ursula Braun <ursula.braun@xxxxxxxxxx>
>> Cc: linux390@xxxxxxxxxx
>> Cc: Frank Blaschka <blaschka@xxxxxxxxxxxxxxxxxx>
>> Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
>> Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
>> Cc: linux-s390@xxxxxxxxxxxxxxx
>> Cc: linux-kernel@xxxxxxxxxxxxxxx
>> Signed-off-by: Stefan Weil <weil@xxxxxxxxxxxxxxx>
>> ---
>>  drivers/s390/net/smsgiucv.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>> 
>> diff --git a/drivers/s390/net/smsgiucv.c b/drivers/s390/net/smsgiucv.c
>> index 65e1cf1..207b7d7 100644
>> --- a/drivers/s390/net/smsgiucv.c
>> +++ b/drivers/s390/net/smsgiucv.c
>> @@ -60,7 +60,7 @@ static struct iucv_handler smsg_handler = {
>>  static int smsg_path_pending(struct iucv_path *path, u8 ipvmid[8],
>>  			     u8 ipuser[16])
>>  {
>> -	if (strncmp(ipvmid, "*MSG    ", sizeof(ipvmid)) != 0)
>> +	if (strncmp(ipvmid, "*MSG    ", 8) != 0)
>
> Hmm, shouldn't this really be  ARRAY_SIZE(ipvmid)  ??

ARRAY_SIZE does not work for the same reason why sizeof does not work:
ipvmid is not an array, it's a pointer.

Andreas.

-- 
Andreas Schwab, schwab@xxxxxxxxxxxxxx
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--
To unsubscribe from this list: send the line "unsubscribe linux-s390" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux