diff --git a/firmware/common/dir.c b/firmware/common/dir.c index 21c5f0100e..4b4a5fa65d 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir.c @@ -128,7 +128,7 @@ DIR* opendir(const char* name) &pdir->fatdir, entry.firstcluster, &pdir->parent_dir) < 0 ) { - DEBUGF("Failed opening dir '%s' (%d)\n", + DEBUGF("Failed opening dir '%s' (%ld)\n", part, entry.firstcluster); pdir->busy = false; return NULL; diff --git a/firmware/common/disk.c b/firmware/common/disk.c index aa42f0793f..923dffbe46 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -39,9 +39,9 @@ 12-15: nr of sectors in partition */ -#define BYTES2INT32(array,pos) \ - (array[pos] | (array[pos+1] << 8 ) | \ - (array[pos+2] << 16 ) | (array[pos+3] << 24 )) +#define BYTES2INT32(array,pos) \ + ((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 */ @@ -76,7 +76,7 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive)) pinfo[i].start = BYTES2INT32(ptr, 8); pinfo[i].size = BYTES2INT32(ptr, 12); - DEBUGF("Part%d: Type %02x, start: %08x size: %08x\n", + DEBUGF("Part%d: Type %02x, start: %08lx size: %08lx\n", i,pinfo[i].type,pinfo[i].start,pinfo[i].size); /* extended? */ diff --git a/firmware/common/file.c b/firmware/common/file.c index 6714b9982c..f04f787b45 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -37,9 +37,9 @@ struct filedesc { unsigned char cache[SECTOR_SIZE]; - int cacheoffset; - int fileoffset; - int size; + int cacheoffset; /* invariant: 0 <= cacheoffset <= SECTOR_SIZE */ + long fileoffset; + long size; int attr; struct fat_file fatfile; bool busy; @@ -380,7 +380,7 @@ static int flush_cache(int fd) { int rc; struct filedesc* file = &openfiles[fd]; - int sector = file->fileoffset / SECTOR_SIZE; + long sector = file->fileoffset / SECTOR_SIZE; DEBUGF("Flushing dirty sector cache\n"); @@ -404,10 +404,10 @@ static int flush_cache(int fd) return 0; } -static int readwrite(int fd, void* buf, int count, bool write) +static int readwrite(int fd, void* buf, long count, bool write) { - int sectors; - int nread=0; + long sectors; + long nread=0; struct filedesc* file = &openfiles[fd]; int rc; @@ -416,8 +416,8 @@ static int readwrite(int fd, void* buf, int count, bool write) return -1; } - LDEBUGF( "readwrite(%d,%x,%d,%s)\n", - fd,buf,count,write?"write":"read"); + LDEBUGF( "readwrite(%d,%lx,%ld,%s)\n", + fd,(long)buf,count,write?"write":"read"); /* attempt to read past EOF? */ if (!write && count > file->size - file->fileoffset) @@ -469,7 +469,7 @@ static int readwrite(int fd, void* buf, int count, bool write) int rc = fat_readwrite(&(file->fatfile), sectors, (unsigned char*)buf+nread, write ); if ( rc < 0 ) { - DEBUGF("Failed read/writing %d sectors\n",sectors); + DEBUGF("Failed read/writing %ld sectors\n",sectors); errno = EIO; if(write && file->fatfile.eof) { DEBUGF("No space left on device\n"); @@ -545,7 +545,7 @@ static int readwrite(int fd, void* buf, int count, bool write) } file->fileoffset += nread; - LDEBUGF("fileoffset: %d\n", file->fileoffset); + LDEBUGF("fileoffset: %ld\n", file->fileoffset); /* adjust file size to length written */ if ( write && file->fileoffset > file->size ) @@ -571,14 +571,14 @@ ssize_t read(int fd, void* buf, size_t count) off_t lseek(int fd, off_t offset, int whence) { - int pos; - int newsector; - int oldsector; + off_t pos; + long newsector; + long oldsector; int sectoroffset; int rc; struct filedesc* file = &openfiles[fd]; - LDEBUGF("lseek(%d,%d,%d)\n",fd,offset,whence); + LDEBUGF("lseek(%d,%ld,%d)\n",fd,offset,whence); if ( !file->busy ) { errno = EBADF; @@ -649,7 +649,7 @@ off_t lseek(int fd, off_t offset, int whence) return pos; } -int filesize(int fd) +off_t filesize(int fd) { struct filedesc* file = &openfiles[fd]; diff --git a/firmware/include/file.h b/firmware/include/file.h index c58139d9d0..e76abaaa96 100644 --- a/firmware/include/file.h +++ b/firmware/include/file.h @@ -86,7 +86,7 @@ extern ssize_t write(int fd, const void *buf, size_t count); extern int remove(const char* pathname); extern int rename(const char* path, const char* newname); extern int ftruncate(int fd, off_t length); -extern int filesize(int fd); +extern off_t filesize(int fd); #endif /* SIMULATOR */ #endif