All of lore.kernel.org
 help / color / mirror / Atom feed
From: OpenBMC Patches <openbmc-patches@stwcx.xyz>
To: openbmc@lists.ozlabs.org
Cc: Nan Li <bjlinan@cn.ibm.com>
Subject: [PATCH openpower-host-ipmi-oem 2/2] Fix endianness issue5
Date: Tue, 24 May 2016 04:40:37 -0500	[thread overview]
Message-ID: <20160524094037.16462-3-openbmc-patches@stwcx.xyz> (raw)
In-Reply-To: <20160524094037.16462-1-openbmc-patches@stwcx.xyz>

From: Nan Li <bjlinan@cn.ibm.com>

Make it safe in both little-endian and big-endian bmc chip.

Signed-off-by: Nan Li <bjlinan@cn.ibm.com>
---
 oemhandler.C | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/oemhandler.C b/oemhandler.C
index 026e0d1..6716618 100644
--- a/oemhandler.C
+++ b/oemhandler.C
@@ -30,8 +30,8 @@ ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
 	FILE *fp;
 	int r = 0;
 	// TODO: Issue 5: This is not endian-safe.
-	short *recid  =  (short*) &reqptr->selrecordls;
-	short *offset =  (short*) &reqptr->offsetls;
+	unsigned short recid  =  ((unsigned short) reqptr->selrecordls) << 8 + reqptr->selrecordms;
+	unsigned short offset =  ((unsigned short) reqptr->offsetls) << 8 + reqptr->offsetms;
 	uint8_t rlen;
 	ipmi_ret_t rc = IPMI_CC_OK;
 	const char *pio;
@@ -59,7 +59,7 @@ ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
 
     // OpenPOWER Host Interface spec says if RecordID and Offset are
 	// 0 then then this is a new request
-	if (!*recid && !*offset)
+	if (!recid && !offset)
 		pio = "wb";
 	else
 		pio = "rb+";
@@ -67,10 +67,10 @@ ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
 	rlen = (*data_len) - (uint8_t) (sizeof(esel_request_t));
 
 	printf("IPMI PARTIAL ESEL for %s  Offset = %d Length = %d\n",
-		g_esel_path, *offset, rlen);
+		g_esel_path, offset, rlen);
 
 	if ((fp = fopen(g_esel_path, pio)) != NULL) {
-		fseek(fp, *offset, SEEK_SET);
+		fseek(fp, offset, SEEK_SET);
 		fwrite(reqptr+1,rlen,1,fp);
 		fclose(fp);
 
-- 
2.8.3

  parent reply	other threads:[~2016-05-24  9:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24  9:40 [PATCH openpower-host-ipmi-oem 0/2] Fix endianness issue5 OpenBMC Patches
2016-05-24  9:40 ` [PATCH openpower-host-ipmi-oem 1/2] Handle multiple attempts at ipmi reservation ids OpenBMC Patches
2016-05-24  9:40 ` OpenBMC Patches [this message]
2016-05-26  0:52   ` [PATCH openpower-host-ipmi-oem 2/2] Fix endianness issue5 Cyril Bur

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=20160524094037.16462-3-openbmc-patches@stwcx.xyz \
    --to=openbmc-patches@stwcx.xyz \
    --cc=bjlinan@cn.ibm.com \
    --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.