All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@ozlabs.org>
To: OpenBMC Patches <openbmc-patches@stwcx.xyz>, openbmc@lists.ozlabs.org
Cc: Nan Li <bjlinan@cn.ibm.com>
Subject: Re: [PATCH openpower-host-ipmi-oem v2] Fix endianness issue5
Date: Thu, 26 May 2016 10:25:34 +0800	[thread overview]
Message-ID: <57465E9E.2000502@ozlabs.org> (raw)
In-Reply-To: <20160526020044.1213-2-openbmc-patches@stwcx.xyz>

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

  reply	other threads:[~2016-05-26  2:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26  2:00 [PATCH openpower-host-ipmi-oem v2] Fix endianness issue5 OpenBMC Patches
2016-05-26  2:00 ` OpenBMC Patches
2016-05-26  2:25   ` Jeremy Kerr [this message]
2016-05-26  3:17     ` Nan KX Li
2016-05-26  3:37     ` Cyril Bur
2016-05-26  6:19       ` Nan KX Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57465E9E.2000502@ozlabs.org \
    --to=jk@ozlabs.org \
    --cc=bjlinan@cn.ibm.com \
    --cc=openbmc-patches@stwcx.xyz \
    --cc=openbmc@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.