[ofa-general] ***SPAM*** [PATCH] libibmad/src/dump.c fix dump functions for big endian machines

Eli Dorfman (Voltaire) dorfman.eli at gmail.com
Wed Feb 4 00:00:05 PST 2009


fix dump functions for big endian machines

Signed-off-by: Eli Dorfman <elid at voltaire.com>
---
 libibmad/src/dump.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libibmad/src/dump.c b/libibmad/src/dump.c
index 1cf5232..3b49158 100644
--- a/libibmad/src/dump.c
+++ b/libibmad/src/dump.c
@@ -46,10 +46,10 @@ void mad_dump_int(char *buf, int bufsz, void *val, int valsz)
 {
 	switch (valsz) {
 	case 1:
-		snprintf(buf, bufsz, "%d", *(uint8_t *) val);
+		snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xff);
 		break;
 	case 2:
-		snprintf(buf, bufsz, "%d", *(uint16_t *) val);
+		snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xffff);
 		break;
 	case 3:
 	case 4:
@@ -71,10 +71,10 @@ void mad_dump_uint(char *buf, int bufsz, void *val, int valsz)
 {
 	switch (valsz) {
 	case 1:
-		snprintf(buf, bufsz, "%u", *(uint8_t *) val);
+		snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xff);
 		break;
 	case 2:
-		snprintf(buf, bufsz, "%u", *(uint16_t *) val);
+		snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xffff);
 		break;
 	case 3:
 	case 4:
@@ -96,10 +96,10 @@ void mad_dump_hex(char *buf, int bufsz, void *val, int valsz)
 {
 	switch (valsz) {
 	case 1:
-		snprintf(buf, bufsz, "0x%02x", *(uint8_t *) val);
+		snprintf(buf, bufsz, "0x%02x", *(uint32_t *) val & 0xff);
 		break;
 	case 2:
-		snprintf(buf, bufsz, "0x%04x", *(uint16_t *) val);
+		snprintf(buf, bufsz, "0x%04x", *(uint32_t *) val & 0xffff);
 		break;
 	case 3:
 		snprintf(buf, bufsz, "0x%06x", *(uint32_t *) val & 0xffffff);
@@ -132,10 +132,10 @@ void mad_dump_rhex(char *buf, int bufsz, void *val, int valsz)
 {
 	switch (valsz) {
 	case 1:
-		snprintf(buf, bufsz, "%02x", *(uint8_t *) val);
+		snprintf(buf, bufsz, "%02x", *(uint32_t *) val & 0xff);
 		break;
 	case 2:
-		snprintf(buf, bufsz, "%04x", *(uint16_t *) val);
+		snprintf(buf, bufsz, "%04x", *(uint32_t *) val & 0xffff);
 		break;
 	case 3:
 		snprintf(buf, bufsz, "%06x", *(uint32_t *) val & 0xffffff);
-- 
1.5.5




More information about the general mailing list