[ofa-general] ***SPAM*** Re: [PATCH] opensm/osm_subnet.c fix parse functions for big endian machines

Eli Dorfman dorfman.eli at gmail.com
Sun Feb 8 09:07:45 PST 2009


On Thu, Feb 5, 2009 at 8:04 PM, Sasha Khapyorsky <sashak at voltaire.com> wrote:
> On 17:19 Thu 05 Feb     , Eli Dorfman (Voltaire) wrote:
>> fix parse functions for big endian machines
>>
>> Signed-off-by: Eli Dorfman <elid at voltaire.com>
>
> Applied. Thanks.
>
> I'm fine with this patch - the code looks cleaner than it was before.
>
> But could you please explain what was a problem with original code on
> big endian machines (I don't see)?

The problem was that setup function that is called from the parse
uint8 function assumed
that void * p_val is a pointer to uint8 but it was uint32


>
> Also it would be helpful to have more detailed patch comments.
>
> Sasha
>
>> ---
>>  opensm/opensm/osm_subnet.c |   10 +++++-----
>>  1 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
>> index d6d39a6..7b33659 100644
>> --- a/opensm/opensm/osm_subnet.c
>> +++ b/opensm/opensm/osm_subnet.c
>> @@ -710,14 +710,14 @@ opts_parse_net16(IN osm_subn_t *p_subn,
>>                 IN void *p_v, IN setup_fn_t pfn)
>>  {
>>       uint16_t *p_val = p_v;
>> -     uint32_t val = strtoul(p_val_str, NULL, 0);
>> +     uint16_t val = strtoul(p_val_str, NULL, 0);
>>
>>       CL_ASSERT(val < 0x10000);
>> -     if (cl_hton32(val) != *p_val) {
>> +     if (cl_hton16(val) != *p_val) {
>>               log_config_value(p_key, "0x%04x", val);
>>               if (pfn)
>>                       pfn(p_subn, &val);
>> -             *p_val = cl_hton16((uint16_t) val);
>> +             *p_val = cl_hton16(val);
>>       }
>>  }
>>
>> @@ -729,14 +729,14 @@ opts_parse_uint8(IN osm_subn_t *p_subn,
>>                 IN void *p_v, IN setup_fn_t pfn)
>>  {
>>       uint8_t *p_val = p_v;
>> -     uint32_t val = strtoul(p_val_str, NULL, 0);
>> +     uint8_t val = strtoul(p_val_str, NULL, 0);
>>
>>       CL_ASSERT(val < 0x100);
>>       if (val != *p_val) {
>>               log_config_value(p_key, "%u", val);
>>               if (pfn)
>>                       pfn(p_subn, &val);
>> -             *p_val = (uint8_t) val;
>> +             *p_val = val;
>>       }
>>  }
>>
>> --
>> 1.5.5
>>
>



More information about the general mailing list