[openib-general] [PATCH] osm: port to WinIB stack - 64 bits

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Sun Oct 15 08:45:29 PDT 2006


Hi Sasha,

Sasha Khapyorsky wrote:
> Hi Evgeny,
> 
> On 16:31 Sun 15 Oct     , Yevgeny Kliteynik wrote:
>> Hi Hal
>>
>> This patch fixes a few data type problems with OSM on 
>> 64-bit Windows machines.
> 
> Could you explain what those problems are?
 
Basically, in all three files the problem was assigning
the result of pointer arithmetics (which is __int64) to 
an int/uint variable.
Casting to int is ok because, as I said, this result is 
actually string length, index in table, or index in string, 
so no range check is required.

--
Yevgeny

> Sasha
> 
> 
>> The changes are done in the following files:
>>
>>   opensm/osm_prtn_config.c
>>   opensm/osm_pkey.c
>>   opensm/osm_qos.c
>>
>> Note that the casting is done on the calculation result, 
>> wich is string lenght, index in table, or index in string,
>> so it's ok to 'downcast' the value.
>>
>> The patch is for trunk only.
>>
>> Yevgeny
>>
>> Signed-off-by:  Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
>>
>> Index: opensm/osm_prtn_config.c
>> ===================================================================
>> --- opensm/osm_prtn_config.c	(revision 9820)
>> +++ opensm/osm_prtn_config.c	(working copy)
>> @@ -254,7 +254,7 @@ static int parse_name_token(char *str, c
>>  		p++;
>>  
>>  	q = p + strlen(p);
>> -	len += q - str + 1;
>> +	len += (int)(q - str) + 1;
>>  	while ( q != p &&
>>  		( *q == '\0' || *q == ' ' || *q == '\t' || *q == '\n'))
>>  		*q-- = '\0';
>> @@ -293,7 +293,7 @@ static int parse_part_conf(struct part_c
>>  	if (*p == '\t' || *p == '\0' || *p == '\n')
>>  		p++;
>>  
>> -	len += p - str;
>> +	len += (int)(p - str);
>>  	str = p;
>>  
>>  	if (conf->p_prtn)
>> Index: opensm/osm_pkey.c
>> ===================================================================
>> --- opensm/osm_pkey.c	(revision 9820)
>> +++ opensm/osm_pkey.c	(working copy)
>> @@ -297,7 +297,7 @@ osm_pkey_tbl_get_block_and_idx(
>>  	(p_pkey < block->pkey_entry + IB_NUM_PKEY_ELEMENTS_IN_BLOCK))
>>      {
>>  	*p_block_idx = block_index;
>> -	*p_pkey_idx = p_pkey - block->pkey_entry;
>> +	*p_pkey_idx = (uint8_t)(p_pkey - block->pkey_entry);
>>  	return(IB_SUCCESS);
>>      }
>>    }
>> Index: opensm/osm_qos.c
>> ===================================================================
>> --- opensm/osm_qos.c	(revision 9820)
>> +++ opensm/osm_qos.c	(working copy)
>> @@ -399,7 +399,7 @@ static int parse_one_unsigned(char *str,
>>  	*val = strtoul(str, &end, 0);
>>  	if (*end)
>>  		end++;
>> -	return end - str;
>> +	return (int)(end - str);
>>  }
>>  
>>  static int parse_vlarb_entry(char *str, ib_vl_arb_element_t * e)
>> @@ -410,7 +410,7 @@ static int parse_vlarb_entry(char *str, 
>>  	e->vl = val % 15;
>>  	p += parse_one_unsigned(p, ',', &val);
>>  	e->weight = (uint8_t)val;
>> -	return p - str;
>> +	return (int)(p - str);
>>  }
>>  
>>  static int parse_sl2vl_entry(char *str, uint8_t * raw)
>> @@ -420,7 +420,7 @@ static int parse_sl2vl_entry(char *str, 
>>  	p += parse_one_unsigned(p, ',', &val1);
>>  	p += parse_one_unsigned(p, ',', &val2);
>>  	*raw = (val1 << 4) | (val2 & 0xf);
>> -	return p - str;
>> +	return (int)(p - str);
>>  }
>>  
>>  static void qos_build_config(struct qos_config *cfg,
>>
>>
>> _______________________________________________
>> openib-general mailing list
>> openib-general at openib.org
>> http://openib.org/mailman/listinfo/openib-general
>>
>> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
>>
> 




More information about the general mailing list