[PATCH 1/2] second/util: convert data to big endian

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If SILO is cross-compiled, the "util" tool will be run in the host system
and we must ensure the output is big-endian.

Signed-off-by: Aaro Koskinen <aaro.koskinen@xxxxxx>
---
 second/util.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/second/util.c b/second/util.c
index 67c9bca..3346823 100644
--- a/second/util.c
+++ b/second/util.c
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
+#include <arpa/inet.h>
 
 FILE *f, *e;
 unsigned char buffer[2048];
@@ -61,11 +62,11 @@ void save(FILE *out, int len, int type)
 			    goto bad1;
 			if (k >= prevoff)
 			    k = prevoff - 1;
-			diffs[type][ndiffs[type]] = k - lastv[type];
+			diffs[type][ndiffs[type]] = htons(k - lastv[type]);
 			lastv[type] = k;
 			ndiffs[type]++;
 		    }
-		    diffs[type][ndiffs[type]] = curoff + j - lastv[type]; 
+		    diffs[type][ndiffs[type]] = htons(curoff + j - lastv[type]);
 		    lastv[type] = curoff + j;
 		    ndiffs[type]++;
 		} else if (buffer2[j] == buffer[j] + 16) {
@@ -77,11 +78,13 @@ void save(FILE *out, int len, int type)
 			    goto bad2;
 			if (k >= prevoff)
 			    k = prevoff - 1;
-			diffs[type+1][ndiffs[type+1]] = k - lastv[type+1];
+			diffs[type+1][ndiffs[type+1]] =
+				htons(k - lastv[type+1]);
 			lastv[type+1] = k;
 			ndiffs[type+1]++;
 		    }
-		    diffs[type+1][ndiffs[type+1]] = curoff + j - lastv[type+1]; 
+		    diffs[type+1][ndiffs[type+1]] =
+			htons(curoff + j - lastv[type+1]);
 		    lastv[type+1] = curoff + j;
 		    ndiffs[type+1]++;
 		} else {
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux