From 4a95eddcd1d599eb0d61677dab0e879e5ea51e78 Mon Sep 17 00:00:00 2001 From: Paul McGougan Date: Thu, 17 Apr 2014 05:09:26 +0000 Subject: mtd: tests: Fix endian issue with CRC generation algorithm The calculation of the CRC in /tests/checkfs/makefiles.c was writing the CRC Into the produced files in host byte-order which would cause CRC validation to fail on big-endian systems as the validation is performed bytewise. Signed-off-by: Paul McGougan [Brian: add endian.h] Signed-off-by: Brian Norris --- tests/checkfs/makefiles.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/checkfs/makefiles.c b/tests/checkfs/makefiles.c index 589280b..52fea54 100644 --- a/tests/checkfs/makefiles.c +++ b/tests/checkfs/makefiles.c @@ -26,6 +26,7 @@ The files are opened in the current dir. */ #include #include +#include #include #include #include @@ -170,6 +171,7 @@ void checksum(char *filename){ printf("Error! Cannot open filename to update checksum: %s\n",filename); exit(1); } + crc = htole16(crc); if(fwrite(&crc, sizeof(crc), 1, fp) != 1){ printf("error! unable to update the file for checksum.\n"); fclose(fp); -- cgit v1.2.3