RE: [PATCH perftest] Avoid configuring the MRs with 1's

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

 



>Hi Ram , 
>I applied your patch and  start to review,
>did you aware that :
>
>       ((char*)ctx->buf[qp_index])[i] = 2 + ((char)rand() % 255);
>       
>Will put values from 2-257 ? 
>       
>Thanks,
>
>Zohar Ben Aharon

X % 255 yields a number between 0 and 254.
Adding 2 to that we get a number between 2 and 256.
Since this is a char the actual number stored is in the range 2 and 255 or 0 (for 256).

HOWEVER, there's still a bug in this line.

(char) should be converted to (unsigned char)

Explanation:
Rand returns a number of 0..<some positive value>
That can turn into 0xff when casting to char. This 0xff *remains* 0xff after the modulo because it is a negative number!
And 0xff+2==1 and the bug occurs again.

I should have verified...

Will send you a fix shortly.

Thank,
Ram



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux