[PATCH openpower-host-ipmi-oem v2] Fix endianness issue5
    Jeremy Kerr 
    jk at ozlabs.org
       
    Thu May 26 12:25:34 AEST 2016
    
    
  
Hi Nan,
You seem to have a minor typo in the commit title there.
> -	// TODO: Issue 5: This is not endian-safe.
> -	short *recid  =  (short*) &reqptr->selrecordls;
> -	short *offset =  (short*) &reqptr->offsetls;
> +
> +	unsigned short recid  =  ((unsigned short) reqptr->selrecordms) << 8 + reqptr->selrecordls;
> +	unsigned short offset =  ((unsigned short) reqptr->offsetms) << 8 + reqptr->offsetls;
That won't do the endian conversion correctly. Can you use one of the
existing endian conversion functions?
The le16toh() function is probably what you want here, from endian.h.
Also, be careful of the change from 'short' to 'unsigned short'.
Regards,
Jeremy
    
    
More information about the openbmc
mailing list