[openib-general] [PATCH 4/13] osm: port to WinIB stack : osmtest/osmtest.c
Eitan Zahavi
eitan at mellanox.co.il
Sun Sep 17 11:50:21 PDT 2006
Hi Michael,
In general I agree we could make the code a little more safe by checking
castings.
But in many of the cases (not the ones with user input -
strtoul/strtoull) it is not required as the values are limited by the IB
arch.
Anyway, the patch I am sending is for WinIB migration. Just doing the
explicit cast does not make things any worst.
We could take the task of cleaning these integer casts (like I did in
osm_pkey.c/h) but this is another patch.
EZ
Michael S. Tsirkin wrote:
>Quoting r. Eitan Zahavi <eitan at mellanox.co.il>:
>
>
>>Subject: [PATCH 4/13] osm: port to WinIB stack : osmtest/osmtest.c
>>
>>Hi Hal
>>
>>Explicit cast required for the win compiler to handle this...
>>
>>Thanks
>>
>>Eitan
>>
>>Signed-off-by: Eitan Zahavi <eitan at mellanox.co.il>
>>
>>Index: osmtest/osmtest.c
>>===================================================================
>>--- osmtest/osmtest.c (revision 9502)
>>+++ osmtest/osmtest.c (working copy)
>>@@ -3281,7 +3281,7 @@ osmtest_validate_path_data( IN osmtest_t
>> else
>> {
>> /* Also, this doesn't detect fewer than the correct number of paths being returned */
>>- if ( p_path->count >= ( 1 << lmc ) * ( 1 << lmc ) )
>>+ if ( p_path->count >= (uint32_t)( 1 << (2*lmc)) )
>> {
>> osm_log( &p_osmt->log, OSM_LOG_ERROR,
>> "osmtest_validate_path_data: ERR 0052: "
>>
>>
>>
>
>Integer casts are ugly, and can mask real errors.
>All you want is for the math result to be unsigned, so
> 1u << (2*lmc)
>would be cleaner with the same effect, I think.
>
>
>
More information about the general
mailing list