From a83214d16f58ce22f0b2b1ea43de857f8ecb7dde Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bernardy Date: Sun, 27 Feb 2005 20:44:26 +0000 Subject: couple of fixes for 16 bits archs git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6073 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/disk.c | 2 +- firmware/drivers/fat.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/firmware/common/disk.c b/firmware/common/disk.c index fd6de55ddb..f4d153c1c2 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -42,7 +42,7 @@ */ #define BYTES2INT32(array,pos) \ - ((long)array[pos] | (long)(array[pos+1] << 8 ) | \ + ((long)array[pos] | ((long)array[pos+1] << 8 ) | \ ((long)array[pos+2] << 16 ) | ((long)array[pos+3] << 24 )) static struct partinfo part[8]; /* space for 4 partitions on 2 drives */ diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 465adec479..cf2665494f 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -1588,8 +1588,10 @@ static int parse_direntry(struct fat_direntry *de, const unsigned char *buf) de->wrtdate = BYTES2INT16(buf,FATDIR_WRTDATE); de->wrttime = BYTES2INT16(buf,FATDIR_WRTTIME); de->filesize = BYTES2INT32(buf,FATDIR_FILESIZE); - de->firstcluster = ((long)BYTES2INT16(buf,FATDIR_FSTCLUSLO)) | - ((long)BYTES2INT16(buf,FATDIR_FSTCLUSHI) << 16); + de->firstcluster = ((long)(unsigned)BYTES2INT16(buf,FATDIR_FSTCLUSLO)) | + ((long)(unsigned)BYTES2INT16(buf,FATDIR_FSTCLUSHI) << 16); + /* The double cast is to prevent a sign-extension to be done on CalmRISC16. + (the result of the shift is always considered signed) */ /* fix the name */ for (i=0; (i<8) && (buf[FATDIR_NAME+i] != ' '); i++) -- cgit v1.2.3