[PATCH openpower-host-ipmi-oem v2] Fix endianness issue5
Nan KX Li
bjlinan at cn.ibm.com
Thu May 26 13:17:19 AEST 2016
Hi Jeremy,
Thanks.
(I missed Cyril's mail.)
I'd use the conversion function to change my commit.
Regards,
William Li ( Li Nan, 李楠 )
Firmware Engineering Professional
OpenPower AE Team | IBM System & Technology Lab
Mobile: +86-186-1081 6605
Beijing, China
From: Jeremy Kerr <jk at ozlabs.org>
To: OpenBMC Patches <openbmc-patches at stwcx.xyz>,
openbmc at lists.ozlabs.org
Cc: Nan KX Li/China/IBM at IBMCN
Date: 05/26/2016 10:27
Subject: Re: [PATCH openpower-host-ipmi-oem v2] Fix endianness
issue5
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160526/a031b9e2/attachment-0001.html>
More information about the openbmc
mailing list