From: Charles Manning Date: Sat, 30 Aug 2014 00:39:40 +0000 (+1200) Subject: Huge cleanup of type warnings etc. X-Git-Url: https://yaffs.net/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=b295567b94e6d4014938e42e978306a13b330bb3 Huge cleanup of type warnings etc. Signed-off-by: Charles Manning --- diff --git a/direct/test-framework/nanddrv.c b/direct/test-framework/nanddrv.c index 5fb05c0..2008ecf 100644 --- a/direct/test-framework/nanddrv.c +++ b/direct/test-framework/nanddrv.c @@ -75,7 +75,6 @@ int nanddrv_read_tr(struct nand_chip *this, int page, { unsigned char status; int ncycles; - unsigned char *buffer; if(n_tr < 1) return 0; @@ -98,7 +97,7 @@ int nanddrv_read_tr(struct nand_chip *this, int page, buffer++; } } else { - unsigned short *buffer = tr->buffer; + unsigned short *buffer = (unsigned short *)tr->buffer; ncycles = tr->nbytes >> 1; while (ncycles> 0) { @@ -145,7 +144,7 @@ int nanddrv_write_tr(struct nand_chip *this, int page, buffer++; } } else { - unsigned short *buffer = tr->buffer; + unsigned short *buffer = (unsigned short *)tr->buffer; ncycles = tr->nbytes >> 1; while (ncycles> 0) { diff --git a/direct/test-framework/nandsim.c b/direct/test-framework/nandsim.c index 9c8a6fe..b012b1c 100644 --- a/direct/test-framework/nandsim.c +++ b/direct/test-framework/nandsim.c @@ -28,6 +28,8 @@ #include #include +#include "yportenv.h" + static int nandsim_debug = 0; #define debug(n, fmt, ...) \ @@ -94,6 +96,8 @@ static void check_last(struct nandsim_private *ns, static void idle(struct nandsim_private *ns, int line) { + YAFFS_UNUSED(line); + ns->read_offset = -1; ns->write_offset = -1; ns->addr_offset = -1; @@ -110,6 +114,7 @@ static void expect_address(struct nandsim_private *ns, int nbytes, int line) { int from; + switch (nbytes) { case 2: case 5: /* contains an offset */ @@ -175,27 +180,34 @@ static void set_offset(struct nandsim_private *ns) static void load_read_buffer(struct nandsim_private *ns) { int addr = get_page_address(ns); + debug(1, "Store read at address %d\n", addr); ns->store->retrieve(ns->store, addr,ns->buffer); } static void save_write_buffer(struct nandsim_private *ns) { int addr = get_page_address(ns); + debug(1, "Store write at address %d\n", addr); ns->store->store(ns->store, addr, ns->buffer); } static void check_read_buffer(struct nandsim_private *ns, int line) { + YAFFS_UNUSED(ns); + YAFFS_UNUSED(line); } static void end_cmd(struct nandsim_private *ns, int line) { + YAFFS_UNUSED(line); ns->last_cmd_byte = 0xff; } static void set_busy(struct nandsim_private *ns, int cycles, int line) { + YAFFS_UNUSED(line); + ns->busy_count = cycles; } @@ -380,11 +392,13 @@ static void read_status(struct nandsim_private *ns) static void read_id(struct nandsim_private *ns) { + YAFFS_UNUSED(ns); } static void unsupported(struct nandsim_private *ns) { + YAFFS_UNUSED(ns); } static void nandsim_cl_write(struct nandsim_private *ns, unsigned char val) @@ -447,7 +461,7 @@ static void nandsim_al_write(struct nandsim_private *ns, unsigned char val) check_not_busy(ns, __LINE__); if(ns->addr_expected < 1 || ns->addr_offset < 0 || - ns->addr_offset >= sizeof(ns->addr_buffer)){ + ns->addr_offset >= (int)sizeof(ns->addr_buffer)){ debug(1, "Address write when not expected\n"); } else { debug(1, "Address write when expecting %d bytes\n", @@ -461,7 +475,7 @@ static void nandsim_al_write(struct nandsim_private *ns, unsigned char val) } } -static void nandsim_dl_write(struct nandsim_private *ns, +static void nandsim_dl_write(struct nandsim_private *ns, unsigned val, int bus_width_shift) { diff --git a/direct/test-framework/tests/Makefile b/direct/test-framework/tests/Makefile index 2fc97f0..5b976b5 100644 --- a/direct/test-framework/tests/Makefile +++ b/direct/test-framework/tests/Makefile @@ -29,7 +29,7 @@ ALL_UNSORTED_OBJS += $(YAFFS_TEST_OBJS) $(FUZZER_OBJS) include ../FrameworkRules.mk -C_FLAGS += -DCONFIG_YAFFS_USE_PTHREADS +CFLAGS += -DCONFIG_YAFFS_USE_PTHREADS -Werror yaffs_test: $(FRAMEWORK_SOURCES) $(YAFFS_TEST_OBJS) gcc $(CFLLAG) -o $@ $(YAFFS_TEST_OBJS) -lpthread diff --git a/direct/test-framework/tests/nor_stress.c b/direct/test-framework/tests/nor_stress.c index 93a9a8e..2d61dcf 100644 --- a/direct/test-framework/tests/nor_stress.c +++ b/direct/test-framework/tests/nor_stress.c @@ -203,7 +203,10 @@ static void dump_directory_tree_worker(const char *dname,int recursive) yaffs_lstat(str,&s); - printf("%s inode %ld %d obj %x length %d mode %X ",str, de->d_ino, s.st_ino,de->d_dont_use,(int)s.st_size,s.st_mode);\ + printf("%s inode %ld obj %d %p length %d mode %X ", + str, de->d_ino, s.st_ino, + de->d_dont_use, (int)s.st_size, s.st_mode); + if(de->d_ino != s.st_ino){ printf(" \n\n!!!! HEY inode mismatch\n\n"); error_line = __LINE__; diff --git a/direct/test-framework/yaffs_fileem.c b/direct/test-framework/yaffs_fileem.c index 96a64c6..b1c1d07 100644 --- a/direct/test-framework/yaffs_fileem.c +++ b/direct/test-framework/yaffs_fileem.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include @@ -36,7 +36,7 @@ -typedef struct +typedef struct { u8 data[528]; // Data + spare } yflash_Page; @@ -44,7 +44,7 @@ typedef struct typedef struct { yflash_Page page[32]; // The pages in the block - + } yflash_Block; @@ -60,56 +60,54 @@ static yflash_Device filedisk; static int CheckInit(struct yaffs_dev *dev) { static int initialised = 0; - int i; - - int fSize; int written; - yflash_Page p; - - if(initialised) + + YAFFS_UNUSED(dev); + + if(initialised) { return YAFFS_OK; } initialised = 1; - - + + filedisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024); - + filedisk.handle = open("emfile-512-0", O_RDWR | O_CREAT, S_IREAD | S_IWRITE); - + if(filedisk.handle < 0) { perror("Failed to open yaffs emulation file"); return YAFFS_FAIL; } - - + + fSize = lseek(filedisk.handle,0,SEEK_END); - + if(fSize < SIZE_IN_MB * 1024 * 1024) { printf("Creating yaffs emulation file\n"); - + lseek(filedisk.handle,0,SEEK_SET); - + memset(&p,0xff,sizeof(yflash_Page)); - + for(i = 0; i < SIZE_IN_MB * 1024 * 1024; i+= 512) { written = write(filedisk.handle,&p,sizeof(yflash_Page)); - + if(written != sizeof(yflash_Page)) { printf("Write failed\n"); return YAFFS_FAIL; } - } + } } - + return 1; } @@ -118,28 +116,24 @@ int yflash_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, int written; CheckInit(dev); - - - + if(data) { lseek(filedisk.handle,nand_chunk * 528,SEEK_SET); written = write(filedisk.handle,data,512); - + if(written != 512) return YAFFS_FAIL; } - + if(spare) { lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET); written = write(filedisk.handle,spare,16); - + if(written != 16) return YAFFS_FAIL; } - - - return YAFFS_OK; + return YAFFS_OK; } @@ -148,28 +142,24 @@ int yflash_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, str int nread; CheckInit(dev); - - - + if(data) { lseek(filedisk.handle,nand_chunk * 528,SEEK_SET); nread = read(filedisk.handle,data,512); - + if(nread != 512) return YAFFS_FAIL; } - + if(spare) { lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET); nread= read(filedisk.handle,spare,16); - + if(nread != 16) return YAFFS_FAIL; } - - - return YAFFS_OK; + return YAFFS_OK; } @@ -177,37 +167,32 @@ int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber) { int i; - + CheckInit(dev); - + if(blockNumber < 0 || blockNumber >= filedisk.nBlocks) { yaffs_trace(YAFFS_TRACE_ALWAYS, "Attempt to erase non-existant block %d\n", blockNumber); return YAFFS_FAIL; - } - else - { - + } else { yflash_Page pg; - + memset(&pg,0xff,sizeof(yflash_Page)); - + lseek(filedisk.handle, blockNumber * 32 * 528, SEEK_SET); - - for(i = 0; i < 32; i++) - { + + for(i = 0; i < 32; i++) { write(filedisk.handle,&pg,528); } return YAFFS_OK; } - } int yflash_InitialiseNAND(struct yaffs_dev *dev) { - + YAFFS_UNUSED(dev); return YAFFS_OK; } diff --git a/direct/test-framework/yaffs_fileem2k.c b/direct/test-framework/yaffs_fileem2k.c index b9a00f1..d3d2656 100644 --- a/direct/test-framework/yaffs_fileem2k.c +++ b/direct/test-framework/yaffs_fileem2k.c @@ -110,12 +110,6 @@ static void yflash2_MaybePowerFail(unsigned int nand_chunk, int failPoint) } } - - - - -static u8 localBuffer[PAGE_SIZE]; - static char *NToName(char *buf,int n) { sprintf(buf,"emfile-2k-%d",n); @@ -154,24 +148,17 @@ static int CheckInit(void) { static int initialised = 0; int i; - int blk; - if(initialised) - { return YAFFS_OK; - } initialised = 1; - srand(random_seed); remaining_ops = (rand() % 1000) * 5; memset(dummyBuffer,0xff,sizeof(dummyBuffer)); - - filedisk.nBlocks = SIZE_IN_MB * BLOCKS_PER_MB; for(i = 0; i < MAX_HANDLES; i++) @@ -180,7 +167,6 @@ static int CheckInit(void) for(i = 0,blk = 0; blk < filedisk.nBlocks; blk+=BLOCKS_PER_HANDLE,i++) filedisk.handle[i] = GetBlockFileHandle(i); - return 1; } @@ -277,7 +263,7 @@ static int yflash2_ReadChunk(struct yaffs_dev *dev, int nand_chunk, static int yflash2_EraseBlock(struct yaffs_dev *dev, int block_no) { - int i; + u32 i; int h; CheckInit(); @@ -292,18 +278,13 @@ static int yflash2_EraseBlock(struct yaffs_dev *dev, int block_no) u8 pg[PAGE_SIZE]; int syz = PAGE_SIZE; - int pos; memset(pg,0xff,syz); - h = filedisk.handle[(block_no / ( BLOCKS_PER_HANDLE))]; - lseek(h,((block_no % BLOCKS_PER_HANDLE) * dev->param.chunks_per_block) * PAGE_SIZE,SEEK_SET); + lseek(h,((block_no % BLOCKS_PER_HANDLE) * dev->param.chunks_per_block) * PAGE_SIZE, SEEK_SET); for(i = 0; i < dev->param.chunks_per_block; i++) - { write(h,pg,PAGE_SIZE); - } - pos = lseek(h, 0,SEEK_CUR); return YAFFS_OK; } @@ -332,8 +313,8 @@ static int yflash2_MarkBad(struct yaffs_dev *dev, int block_no) static int yflash2_CheckBad(struct yaffs_dev *dev, int block_no) { - (void) dev; - (void) block_no; + YAFFS_UNUSED(dev); + YAFFS_UNUSED(block_no); return YAFFS_OK; } diff --git a/direct/test-framework/yaffs_m18_drv.c b/direct/test-framework/yaffs_m18_drv.c index 9a8ee49..4403100 100644 --- a/direct/test-framework/yaffs_m18_drv.c +++ b/direct/test-framework/yaffs_m18_drv.c @@ -224,6 +224,8 @@ static int m18_drv_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk); u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk); + YAFFS_UNUSED(data_len); + if(data) { m18_drv_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / 4); @@ -305,7 +307,7 @@ static int m18_drv_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber) static int m18_drv_InitialiseNAND(struct yaffs_dev *dev) { - int i; + u32 i; m18_drv_FlashInit(); /* Go through the blocks formatting them if they are not formatted */ diff --git a/direct/test-framework/yaffs_nand_drv.c b/direct/test-framework/yaffs_nand_drv.c index 9bdcb55..f739d1d 100644 --- a/direct/test-framework/yaffs_nand_drv.c +++ b/direct/test-framework/yaffs_nand_drv.c @@ -83,7 +83,7 @@ static int yaffs_nand_drv_WriteChunk(struct yaffs_dev *dev, int nand_chunk, /* Set up and execute transfer */ - tr[0].buffer = data; + tr[0].buffer = (u8 *)data; tr[0].offset = 0; tr[0].nbytes = data_len; @@ -196,8 +196,6 @@ static int yaffs_nand_drv_CheckBad(struct yaffs_dev *dev, int block_no) struct nand_chip *chip = dev_to_chip(dev); u8 *buffer = dev_to_buffer(dev); int nand_chunk = block_no * chip->pages_per_block; - int ret; - struct nanddrv_transfer tr[1]; memset(buffer, 0, chip->spare_bytes_per_page); @@ -206,7 +204,7 @@ static int yaffs_nand_drv_CheckBad(struct yaffs_dev *dev, int block_no) tr[0].offset = chip->data_bytes_per_page; tr[0].nbytes = chip->spare_bytes_per_page; - ret = nanddrv_read_tr(chip, nand_chunk, tr, 1); + nanddrv_read_tr(chip, nand_chunk, tr, 1); /* Check that bad block marker is not set */ if(yaffs_hweight8(buffer[0]) + yaffs_hweight8(buffer[1]) < 14) diff --git a/direct/test-framework/yaffs_nandsim_file.c b/direct/test-framework/yaffs_nandsim_file.c index 962b3d6..4c00d56 100644 --- a/direct/test-framework/yaffs_nandsim_file.c +++ b/direct/test-framework/yaffs_nandsim_file.c @@ -13,7 +13,7 @@ #include "yaffs_nandsim_file.h" - +#include "yaffs_nand_drv.h" #include "nandsim_file.h" #include "nand_chip.h" #include "yaffs_guts.h" diff --git a/direct/test-framework/yaffs_nandsim_file.h b/direct/test-framework/yaffs_nandsim_file.h index 0960dac..fc0ece2 100644 --- a/direct/test-framework/yaffs_nandsim_file.h +++ b/direct/test-framework/yaffs_nandsim_file.h @@ -13,12 +13,12 @@ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ -#ifndef __YAFFS_NAND_DRV_H__ -#define __YAFFS_NAND_DRV_H__ +#ifndef __YAFFS_NAND_SIM_FILE_DRV_H__ +#define __YAFFS_NAND_SIM_FILE_DRV_H__ struct yaffs_dev; -struct yaffs_dev *yaffs_nandsim_file_install(const char *dev_name, +struct yaffs_dev *yaffs_nandsim_install_drv(const char *dev_name, const char *backing_file_name, int n_blocks); diff --git a/direct/test-framework/yaffs_nor_drv.c b/direct/test-framework/yaffs_nor_drv.c index 7ac108a..f9511d2 100644 --- a/direct/test-framework/yaffs_nor_drv.c +++ b/direct/test-framework/yaffs_nor_drv.c @@ -199,6 +199,8 @@ static int nor_drv_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk); u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk); + YAFFS_UNUSED(data_len); + if (data) { nor_drv_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / sizeof(u32)); } @@ -278,7 +280,7 @@ static int nor_drv_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber) static int nor_drv_InitialiseNAND(struct yaffs_dev *dev) { - int i; + u32 i; nor_drv_FlashInit(); /* Go through the blocks formatting them if they are not formatted */ diff --git a/direct/test-framework/yaffs_osglue.c b/direct/test-framework/yaffs_osglue.c index e31ad22..e686bd7 100644 --- a/direct/test-framework/yaffs_osglue.c +++ b/direct/test-framework/yaffs_osglue.c @@ -53,6 +53,9 @@ int yaffsfs_GetLastError(void) */ int yaffsfs_CheckMemRegion(const void *addr, size_t size, int write_request) { + YAFFS_UNUSED(size); + YAFFS_UNUSED(write_request); + if(!addr) return -1; return 0; @@ -91,6 +94,8 @@ static void *bg_gc_func(void *dummy) int result; int next_urgent; + YAFFS_UNUSED(dummy); + /* Sleep for a bit to allow start up */ sleep(2); diff --git a/direct/test-framework/yaffs_ramdisk.c b/direct/test-framework/yaffs_ramdisk.c index 3d71e51..f0e5933 100644 --- a/direct/test-framework/yaffs_ramdisk.c +++ b/direct/test-framework/yaffs_ramdisk.c @@ -36,7 +36,7 @@ -typedef struct +typedef struct { u8 data[528]; // Data + spare } yramdisk_page; @@ -44,7 +44,7 @@ typedef struct typedef struct { yramdisk_page page[32]; // The pages in the block - + } yramdisk_block; @@ -60,31 +60,30 @@ static yramdisk_device ramdisk; static int CheckInit(struct yaffs_dev *dev) { static int initialised = 0; - + int i; int fail = 0; - //int nBlocks; int nAllocated = 0; - - if(initialised) + + if(initialised) { return YAFFS_OK; } initialised = 1; - - + + ramdisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024); - + ramdisk.block = malloc(sizeof(yramdisk_block *) * ramdisk.nBlocks); - + if(!ramdisk.block) return 0; - + for(i=0; i page[pg].data,data,512); } - - + + if(tags) { struct yaffs_packed_tags1 pt; - + yaffs_pack_tags1(&pt,tags); memcpy(&ramdisk.block[blk]->page[pg].data[512],&pt,sizeof(pt)); } - return YAFFS_OK; + return YAFFS_OK; } @@ -152,26 +151,26 @@ int yramdisk_rd_chunk(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaf int blk; int pg; - + CheckInit(dev); - + blk = nand_chunk/32; pg = nand_chunk%32; - - + + if(data) { memcpy(data,ramdisk.block[blk]->page[pg].data,512); } - - + + if(tags) { struct yaffs_packed_tags1 pt; - + memcpy(&pt,&ramdisk.block[blk]->page[pg].data[512],sizeof(pt)); yaffs_unpack_tags1(tags,&pt); - + } return YAFFS_OK; @@ -184,13 +183,13 @@ int yramdisk_check_chunk_erased(struct yaffs_dev *dev,int nand_chunk) int pg; int i; - + CheckInit(dev); - + blk = nand_chunk/32; pg = nand_chunk%32; - - + + for(i = 0; i < 528; i++) { if(ramdisk.block[blk]->page[pg].data[i] != 0xFF) @@ -205,9 +204,9 @@ int yramdisk_check_chunk_erased(struct yaffs_dev *dev,int nand_chunk) int yramdisk_erase(struct yaffs_dev *dev, int blockNumber) { - + CheckInit(dev); - + if(blockNumber < 0 || blockNumber >= ramdisk.nBlocks) { yaffs_trace(YAFFS_TRACE_ALWAYS, @@ -220,14 +219,13 @@ int yramdisk_erase(struct yaffs_dev *dev, int blockNumber) memset(ramdisk.block[blockNumber],0xFF,sizeof(yramdisk_block)); return YAFFS_OK; } - + } int yramdisk_initialise(struct yaffs_dev *dev) { - //dev->use_nand_ecc = 1; // force on use_nand_ecc which gets faked. - // This saves us doing ECC checks. - + YAFFS_UNUSED(dev); + return YAFFS_OK; } diff --git a/direct/test-framework/yaffs_ramem2k.c b/direct/test-framework/yaffs_ramem2k.c index 715ae77..b281dd4 100644 --- a/direct/test-framework/yaffs_ramem2k.c +++ b/direct/test-framework/yaffs_ramem2k.c @@ -49,7 +49,7 @@ #define BLOCKS_PER_MEG ((1<<20)/(PAGES_PER_BLOCK * PAGE_DATA_SIZE)) -typedef struct +typedef struct { u8 data[PAGE_TOTAL_SIZE]; // Data + spare int empty; // is this empty? @@ -59,7 +59,7 @@ typedef struct typedef struct { nandemul_Page *page[PAGES_PER_BLOCK]; - int damaged; + int damaged; } nandemul_Block; @@ -79,6 +79,8 @@ static void nandemul_yield(int n) { #ifdef __KERNEL__ if(n > 0) schedule_timeout(n); +#else + YAFFS_UNUSED(n); #endif } @@ -87,16 +89,16 @@ static void nandemul_yield(int n) static void nandemul_ReallyEraseBlock(int blockNumber) { int i; - + nandemul_Block *blk; - + if(blockNumber < 0 || blockNumber >= ned.nBlocks) { return; } - + blk = ned.block[blockNumber]; - + for(i = 0; i < PAGES_PER_BLOCK; i++) { memset(blk->page[i],0xff,sizeof(nandemul_Page)); @@ -116,40 +118,40 @@ static int nandemul2k_CalcNBlocks(void) static int CheckInit(void) { static int initialised = 0; - + int i,j; - + int fail = 0; - int nBlocks; + int nBlocks; int nAllocated = 0; - - if(initialised) + + if(initialised) { return YAFFS_OK; } - - + + ned.nBlocks = nBlocks = nandemul2k_CalcNBlocks(); - + ned.block = malloc(sizeof(nandemul_Block*) * nBlocks ); - + if(!ned.block) return YAFFS_FAIL; - - - - + + + + for(i=fail=0; i page[pg]->data; - + for(i = 0; i < PAGE_DATA_SIZE; i++) { x[i] &=data[i]; @@ -212,16 +214,16 @@ int nandemul2k_WriteChunkWithTagsToNAND(struct yaffs_dev *dev,int nand_chunk,con ned.block[blk]->page[pg]->empty = 0; } - - + + if(tags) { x = &ned.block[blk]->page[pg]->data[PAGE_DATA_SIZE]; - + yaffs_pack_tags2((struct yaffs_packed_tags2 *)x,tags, !dev->param.no_tags_ecc); - + } - + if(tags || data) { nandemul_yield(1); @@ -235,60 +237,35 @@ int nandemul2k_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,int nand_chunk, u { int blk; int pg; - + u8 *x; - - + + blk = nand_chunk/PAGES_PER_BLOCK; pg = nand_chunk%PAGES_PER_BLOCK; - - + + if(data) { memcpy(data,ned.block[blk]->page[pg]->data,PAGE_DATA_SIZE); } - - + + if(tags) { x = &ned.block[blk]->page[pg]->data[PAGE_DATA_SIZE]; - - yaffs_unpack_tags2(tags,(struct yaffs_packed_tags2 *)x, !dev->param.no_tags_ecc); - } - - return YAFFS_OK; -} - - -static int nandemul2k_CheckChunkErased(struct yaffs_dev *dev,int nand_chunk) -{ - int blk; - int pg; - int i; - - - blk = nand_chunk/PAGES_PER_BLOCK; - pg = nand_chunk%PAGES_PER_BLOCK; - - - for(i = 0; i < PAGE_TOTAL_SIZE; i++) - { - if(ned.block[blk]->page[pg]->data[i] != 0xFF) - { - return YAFFS_FAIL; - } + yaffs_unpack_tags2(tags,(struct yaffs_packed_tags2 *)x, !dev->param.no_tags_ecc); } return YAFFS_OK; - } int nandemul2k_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber) { - - + YAFFS_UNUSED(dev); + if(blockNumber < 0 || blockNumber >= ned.nBlocks) { yaffs_trace(YAFFS_TRACE_ALWAYS, @@ -305,28 +282,31 @@ int nandemul2k_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber) { nandemul_ReallyEraseBlock(blockNumber); } - + return YAFFS_OK; } int nandemul2k_InitialiseNAND(struct yaffs_dev *dev) { + YAFFS_UNUSED(dev); + CheckInit(); return YAFFS_OK; } - + int nandemul2k_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no) { - u8 *x; - + + YAFFS_UNUSED(dev); + x = &ned.block[block_no]->page[0]->data[PAGE_DATA_SIZE]; - + memset(x,0,sizeof(struct yaffs_packed_tags2)); - - + + return YAFFS_OK; - + } int nandemul2k_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, u32 *seq_number) @@ -334,10 +314,12 @@ int nandemul2k_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_bl struct yaffs_ext_tags tags; int chunkNo; + YAFFS_UNUSED(dev); + *seq_number = 0; - + chunkNo = block_no * dev->param.chunks_per_block; - + nandemul2k_ReadChunkWithTagsFromNAND(dev,chunkNo,NULL,&tags); if(tags.block_bad) { @@ -355,10 +337,19 @@ int nandemul2k_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_bl return YAFFS_OK; } -int nandemul2k_GetBytesPerChunk(void) { return PAGE_DATA_SIZE;} +int nandemul2k_GetBytesPerChunk(void) +{ + return PAGE_DATA_SIZE; +} + +int nandemul2k_GetChunksPerBlock(void) +{ + return PAGES_PER_BLOCK; +} -int nandemul2k_GetChunksPerBlock(void) { return PAGES_PER_BLOCK; } -int nandemul2k_GetNumberOfBlocks(void) {return nandemul2k_CalcNBlocks();} +int nandemul2k_GetNumberOfBlocks(void) { + return nandemul2k_CalcNBlocks(); +} #endif //YAFFS_RAM_ENABLED diff --git a/direct/test-framework/yaffscfg2k.c b/direct/test-framework/yaffscfg2k.c index b053ce4..fc9466b 100644 --- a/direct/test-framework/yaffscfg2k.c +++ b/direct/test-framework/yaffscfg2k.c @@ -25,6 +25,7 @@ #include "yaffs_nandemul2k.h" #include "yaffs_trace.h" #include "yaffs_osglue.h" +#include "yaffs_nandsim_file.h" #include diff --git a/direct/yaffs_attribs.c b/direct/yaffs_attribs.c index de80fe4..db6bb29 100644 --- a/direct/yaffs_attribs.c +++ b/direct/yaffs_attribs.c @@ -88,6 +88,8 @@ void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c) #endif } +#if 0 + static Y_LOFF_T yaffs_get_file_size(struct yaffs_obj *obj) { YCHAR *alias = NULL; @@ -106,3 +108,4 @@ static Y_LOFF_T yaffs_get_file_size(struct yaffs_obj *obj) } } +#endif diff --git a/direct/yaffs_qsort.c b/direct/yaffs_qsort.c index afd1ffa..608ec8b 100644 --- a/direct/yaffs_qsort.c +++ b/direct/yaffs_qsort.c @@ -150,10 +150,10 @@ loop: SWAPINIT(a, es); r = min((long)(pd - pc), (long)(pn - pd - es)); vecswap(pb, pn - r, r); r = pb - pa; - if (r > es) + if (r > (int)es) yaffs_qsort(a, r / es, es, cmp); r = pd - pc; - if (r > es) { + if (r > (int)es) { /* Iterate rather than recurse to save stack space */ a = pn - r; n = r / es; diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 6d97cbf..87d9980 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -43,7 +43,7 @@ static yaffs_DIR *yaffsfs_opendir_reldir_no_lock( struct yaffs_obj *reldir, const YCHAR *dirname); static int yaffsfs_closedir_no_lock(yaffs_DIR *dirent); -unsigned int yaffs_wr_attempts; +int yaffs_wr_attempts; /* * Handle management. @@ -783,7 +783,7 @@ int yaffs_dup(int handle) static int yaffsfs_TooManyObjects(struct yaffs_dev *dev) { - int current_objects = dev->n_obj - dev->n_deleted_files; + u32 current_objects = dev->n_obj - dev->n_deleted_files; if (dev->param.max_objects && current_objects > dev->param.max_objects) return 1; @@ -1139,7 +1139,7 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte, Y_LOFF_T startPos = 0; Y_LOFF_T endPos = 0; int nRead = 0; - int nToRead = 0; + unsigned int nToRead = 0; int totalRead = 0; Y_LOFF_T maxRead; u8 *buf = (u8 *) vbuf; @@ -1161,9 +1161,6 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte, /* Not a reading handle */ yaffsfs_SetError(-EINVAL); totalRead = -1; - } else if (nbyte > YAFFS_MAX_FILE_SIZE) { - yaffsfs_SetError(-EINVAL); - totalRead = -1; } else { if (isPread) startPos = offset; @@ -1185,7 +1182,6 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte, endPos = pos + nbyte; if (pos < 0 || pos > YAFFS_MAX_FILE_SIZE || - nbyte > YAFFS_MAX_FILE_SIZE || endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) { totalRead = -1; nbyte = 0; @@ -1213,7 +1209,7 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte, buf += nRead; } - if (nRead == nToRead) + if (nRead == (int)nToRead) nbyte -= nRead; else nbyte = 0; /* no more to read */ @@ -1263,7 +1259,7 @@ static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte, int nWritten = 0; int totalWritten = 0; int write_trhrough = 0; - int nToWrite = 0; + unsigned int nToWrite = 0; const u8 *buf = (const u8 *)vbuf; if (yaffsfs_CheckMemRegion(vbuf, nbyte, 0) < 0) { @@ -1298,7 +1294,6 @@ static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte, endPos = pos + nbyte; if (pos < 0 || pos > YAFFS_MAX_FILE_SIZE || - nbyte > YAFFS_MAX_FILE_SIZE || endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) { totalWritten = -1; nbyte = 0; @@ -1328,7 +1323,7 @@ static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte, buf += nWritten; } - if (nWritten == nToWrite) + if (nWritten == (int)nToWrite) nbyte -= nToWrite; else nbyte = 0; @@ -1714,7 +1709,7 @@ static int yaffsfs_DoStat(struct yaffs_obj *obj, struct yaffs_stat *buf) obj = yaffs_get_equivalent_obj(obj); if (obj && buf) { - buf->st_dev = (int)obj->my_dev->os_context; + buf->st_dev = 0; buf->st_ino = obj->obj_id; buf->st_mode = obj->yst_mode & ~S_IFMT; @@ -3491,7 +3486,7 @@ struct yaffs_dirent *yaffsfs_readdir_no_lock(yaffs_DIR * dirp) if (dsc->nextReturn) { dsc->de.d_ino = yaffs_get_equivalent_obj(dsc->nextReturn)->obj_id; - dsc->de.d_dont_use = (unsigned)dsc->nextReturn; + dsc->de.d_dont_use = dsc->nextReturn; dsc->de.d_off = dsc->offset++; yaffs_get_obj_name(dsc->nextReturn, dsc->de.d_name, NAME_MAX); diff --git a/direct/yaffsfs.h b/direct/yaffsfs.h index 8daf9d6..641f683 100644 --- a/direct/yaffsfs.h +++ b/direct/yaffsfs.h @@ -46,7 +46,7 @@ struct yaffs_dirent { unsigned short d_reclen; /* length of this dirent */ YUCHAR d_type; /* type of this record */ YCHAR d_name[NAME_MAX+1]; /* file name (null-terminated) */ - unsigned d_dont_use; /* debug: not for public consumption */ + void *d_dont_use; /* debug pointer used by test harness */ }; typedef struct opaque_structure yaffs_DIR; @@ -54,7 +54,7 @@ typedef struct opaque_structure yaffs_DIR; struct yaffs_stat { - int st_dev; /* device */ + int st_dev; /* device - unused*/ int st_ino; /* inode */ unsigned st_mode; /* protection */ int st_nlink; /* number of hard links */ diff --git a/direct/yportenv.h b/direct/yportenv.h index 526b38d..2cc6540 100644 --- a/direct/yportenv.h +++ b/direct/yportenv.h @@ -27,6 +27,8 @@ typedef signed int s32; #endif +#define YAFFS_UNUSED(x) (void)(x) + #ifdef CONFIG_YAFFS_PROVIDE_DEFS /* File types */ diff --git a/yaffs_bitmap.c b/yaffs_bitmap.c index 4440e93..41af707 100644 --- a/yaffs_bitmap.c +++ b/yaffs_bitmap.c @@ -17,7 +17,7 @@ * Chunk bitmap manipulations */ -static inline u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk) +static inline u8 *yaffs_block_bits(struct yaffs_dev *dev, u32 blk) { if (blk < dev->internal_start_block || blk > dev->internal_end_block) { yaffs_trace(YAFFS_TRACE_ERROR, @@ -29,10 +29,11 @@ static inline u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk) (dev->chunk_bit_stride * (blk - dev->internal_start_block)); } -void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk) +void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, u32 blk, u32 chunk) { - if (blk < dev->internal_start_block || blk > dev->internal_end_block || - chunk < 0 || chunk >= dev->param.chunks_per_block) { + if (blk < dev->internal_start_block || + blk > dev->internal_end_block || + chunk >= dev->param.chunks_per_block) { yaffs_trace(YAFFS_TRACE_ERROR, "Chunk Id (%d:%d) invalid", blk, chunk); @@ -40,14 +41,14 @@ void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk) } } -void yaffs_clear_chunk_bits(struct yaffs_dev *dev, int blk) +void yaffs_clear_chunk_bits(struct yaffs_dev *dev, u32 blk) { u8 *blk_bits = yaffs_block_bits(dev, blk); memset(blk_bits, 0, dev->chunk_bit_stride); } -void yaffs_clear_chunk_bit(struct yaffs_dev *dev, int blk, int chunk) +void yaffs_clear_chunk_bit(struct yaffs_dev *dev, u32 blk, u32 chunk) { u8 *blk_bits = yaffs_block_bits(dev, blk); @@ -55,7 +56,7 @@ void yaffs_clear_chunk_bit(struct yaffs_dev *dev, int blk, int chunk) blk_bits[chunk / 8] &= ~(1 << (chunk & 7)); } -void yaffs_set_chunk_bit(struct yaffs_dev *dev, int blk, int chunk) +void yaffs_set_chunk_bit(struct yaffs_dev *dev, u32 blk, u32 chunk) { u8 *blk_bits = yaffs_block_bits(dev, blk); @@ -63,7 +64,7 @@ void yaffs_set_chunk_bit(struct yaffs_dev *dev, int blk, int chunk) blk_bits[chunk / 8] |= (1 << (chunk & 7)); } -int yaffs_check_chunk_bit(struct yaffs_dev *dev, int blk, int chunk) +int yaffs_check_chunk_bit(struct yaffs_dev *dev, u32 blk, u32 chunk) { u8 *blk_bits = yaffs_block_bits(dev, blk); @@ -71,10 +72,10 @@ int yaffs_check_chunk_bit(struct yaffs_dev *dev, int blk, int chunk) return (blk_bits[chunk / 8] & (1 << (chunk & 7))) ? 1 : 0; } -int yaffs_still_some_chunks(struct yaffs_dev *dev, int blk) +int yaffs_still_some_chunks(struct yaffs_dev *dev, u32 blk) { u8 *blk_bits = yaffs_block_bits(dev, blk); - int i; + u32 i; for (i = 0; i < dev->chunk_bit_stride; i++) { if (*blk_bits) @@ -84,10 +85,10 @@ int yaffs_still_some_chunks(struct yaffs_dev *dev, int blk) return 0; } -int yaffs_count_chunk_bits(struct yaffs_dev *dev, int blk) +int yaffs_count_chunk_bits(struct yaffs_dev *dev, u32 blk) { u8 *blk_bits = yaffs_block_bits(dev, blk); - int i; + u32 i; int n = 0; for (i = 0; i < dev->chunk_bit_stride; i++, blk_bits++) diff --git a/yaffs_bitmap.h b/yaffs_bitmap.h index e26b37d..d3bf91d 100644 --- a/yaffs_bitmap.h +++ b/yaffs_bitmap.h @@ -22,12 +22,12 @@ #include "yaffs_guts.h" -void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk); -void yaffs_clear_chunk_bits(struct yaffs_dev *dev, int blk); -void yaffs_clear_chunk_bit(struct yaffs_dev *dev, int blk, int chunk); -void yaffs_set_chunk_bit(struct yaffs_dev *dev, int blk, int chunk); -int yaffs_check_chunk_bit(struct yaffs_dev *dev, int blk, int chunk); -int yaffs_still_some_chunks(struct yaffs_dev *dev, int blk); -int yaffs_count_chunk_bits(struct yaffs_dev *dev, int blk); +void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, u32 blk, u32 chunk); +void yaffs_clear_chunk_bits(struct yaffs_dev *dev, u32 blk); +void yaffs_clear_chunk_bit(struct yaffs_dev *dev, u32 blk, u32 chunk); +void yaffs_set_chunk_bit(struct yaffs_dev *dev, u32 blk, u32 chunk); +int yaffs_check_chunk_bit(struct yaffs_dev *dev, u32 blk, u32 chunk); +int yaffs_still_some_chunks(struct yaffs_dev *dev, u32 blk); +int yaffs_count_chunk_bits(struct yaffs_dev *dev, u32 blk); #endif diff --git a/yaffs_checkptrw.c b/yaffs_checkptrw.c index e739fb4..f67d6be 100644 --- a/yaffs_checkptrw.c +++ b/yaffs_checkptrw.c @@ -16,7 +16,7 @@ struct yaffs_checkpt_chunk_hdr { int version; - int seq; + u32 seq; u32 sum; u32 xor; } ; @@ -72,7 +72,7 @@ static int yaffs2_checkpt_space_ok(struct yaffs_dev *dev) static int yaffs_checkpt_erase(struct yaffs_dev *dev) { - int i; + u32 i; if (!dev->drv.drv_erase_fn) return 0; @@ -111,7 +111,7 @@ static int yaffs_checkpt_erase(struct yaffs_dev *dev) static void yaffs2_checkpt_find_erased_block(struct yaffs_dev *dev) { - int i; + u32 i; int blocks_avail = dev->n_erased_blocks - dev->param.n_reserved_blocks; yaffs_trace(YAFFS_TRACE_CHECKPOINT, @@ -119,7 +119,7 @@ static void yaffs2_checkpt_find_erased_block(struct yaffs_dev *dev) dev->n_erased_blocks, dev->param.n_reserved_blocks, blocks_avail, dev->checkpt_next_block); - if (dev->checkpt_next_block >= 0 && + if (dev->checkpt_next_block >= dev->internal_start_block && dev->checkpt_next_block <= dev->internal_end_block && blocks_avail > 0) { @@ -139,13 +139,13 @@ static void yaffs2_checkpt_find_erased_block(struct yaffs_dev *dev) } yaffs_trace(YAFFS_TRACE_CHECKPOINT, "out of checkpt blocks"); - dev->checkpt_next_block = -1; - dev->checkpt_cur_block = -1; + dev->checkpt_next_block = 0; + dev->checkpt_cur_block = 0; } static void yaffs2_checkpt_find_block(struct yaffs_dev *dev) { - int i; + u32 i; struct yaffs_ext_tags tags; yaffs_trace(YAFFS_TRACE_CHECKPOINT, @@ -155,7 +155,7 @@ static void yaffs2_checkpt_find_block(struct yaffs_dev *dev) if (dev->blocks_in_checkpt < dev->checkpt_max_blocks) for (i = dev->checkpt_next_block; i <= dev->internal_end_block; i++) { - int chunk = i * dev->param.chunks_per_block; + u32 chunk = i * dev->param.chunks_per_block; enum yaffs_block_state state; u32 seq; @@ -189,8 +189,8 @@ static void yaffs2_checkpt_find_block(struct yaffs_dev *dev) yaffs_trace(YAFFS_TRACE_CHECKPOINT, "found no more checkpt blocks"); - dev->checkpt_next_block = -1; - dev->checkpt_cur_block = -1; + dev->checkpt_next_block = 0; + dev->checkpt_cur_block = 0; } int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing) @@ -219,8 +219,8 @@ int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing) dev->checkpt_byte_count = 0; dev->checkpt_sum = 0; dev->checkpt_xor = 0; - dev->checkpt_cur_block = -1; - dev->checkpt_cur_chunk = -1; + dev->checkpt_cur_block = 0; + dev->checkpt_cur_chunk = 0; dev->checkpt_next_block = dev->internal_start_block; if (writing) { @@ -264,12 +264,12 @@ static int yaffs2_checkpt_flush_buffer(struct yaffs_dev *dev) int offset_chunk; struct yaffs_ext_tags tags; - if (dev->checkpt_cur_block < 0) { + if (dev->checkpt_cur_block < dev->internal_start_block) { yaffs2_checkpt_find_erased_block(dev); dev->checkpt_cur_chunk = 0; } - if (dev->checkpt_cur_block < 0) + if (dev->checkpt_cur_block < dev->internal_start_block) return 0; tags.is_deleted = 0; @@ -305,7 +305,7 @@ static int yaffs2_checkpt_flush_buffer(struct yaffs_dev *dev) dev->checkpt_cur_chunk++; if (dev->checkpt_cur_chunk >= dev->param.chunks_per_block) { dev->checkpt_cur_chunk = 0; - dev->checkpt_cur_block = -1; + dev->checkpt_cur_block = 0; } memset(dev->checkpt_buffer, 0, dev->data_bytes_per_chunk); @@ -337,8 +337,7 @@ int yaffs2_checkpt_wr(struct yaffs_dev *dev, const void *data, int n_bytes) data_bytes++; dev->checkpt_byte_count++; - if (dev->checkpt_byte_offs < 0 || - dev->checkpt_byte_offs >= dev->data_bytes_per_chunk) + if (dev->checkpt_byte_offs >= dev->data_bytes_per_chunk) ok = yaffs2_checkpt_flush_buffer(dev); } @@ -362,15 +361,16 @@ int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes) while (i < n_bytes && ok) { - if (dev->checkpt_byte_offs < 0 || - dev->checkpt_byte_offs >= dev->data_bytes_per_chunk) { + if (dev->checkpt_byte_offs >= dev->data_bytes_per_chunk) { - if (dev->checkpt_cur_block < 0) { + if (dev->checkpt_cur_block < + dev->internal_start_block) { yaffs2_checkpt_find_block(dev); dev->checkpt_cur_chunk = 0; } - if (dev->checkpt_cur_block < 0) { + if (dev->checkpt_cur_block < + dev->internal_start_block) { ok = 0; break; } @@ -402,9 +402,9 @@ int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes) dev->checkpt_page_seq++; dev->checkpt_cur_chunk++; - if (dev->checkpt_cur_chunk >= + if (dev->checkpt_cur_chunk > dev->param.chunks_per_block) - dev->checkpt_cur_block = -1; + dev->checkpt_cur_block = 0; } @@ -431,8 +431,8 @@ int yaffs_checkpt_close(struct yaffs_dev *dev) } else if (dev->checkpt_block_list) { for (i = 0; i < dev->blocks_in_checkpt && - dev->checkpt_block_list[i] >= 0; i++) { - int blk = dev->checkpt_block_list[i]; + dev->checkpt_block_list[i] > 0; i++) { + u32 blk = dev->checkpt_block_list[i]; struct yaffs_block_info *bi = NULL; if (dev->internal_start_block <= blk && diff --git a/yaffs_getblockinfo.h b/yaffs_getblockinfo.h index 8fd0802..8b58077 100644 --- a/yaffs_getblockinfo.h +++ b/yaffs_getblockinfo.h @@ -21,11 +21,11 @@ /* Function to manipulate block info */ static inline struct yaffs_block_info *yaffs_get_block_info(struct yaffs_dev - *dev, int blk) + *dev, u32 blk) { if (blk < dev->internal_start_block || blk > dev->internal_end_block) { yaffs_trace(YAFFS_TRACE_ERROR, - "**>> yaffs: get_block_info block %d is not valid", + "**>> yaffs: get_block_info block %u is not valid", blk); BUG(); } diff --git a/yaffs_guts.c b/yaffs_guts.c index aee80de..e896ffd 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -34,12 +34,14 @@ #define YAFFS_GC_GOOD_ENOUGH 2 #define YAFFS_GC_PASSIVE_THRESHOLD 4 +#define YAFFS_MAX_CACHE_USAGE 100000000 + #include "yaffs_ecc.h" /* Forward declarations */ static int yaffs_wr_data_obj(struct yaffs_obj *in, int inode_chunk, - const u8 *buffer, int n_bytes, int use_reserve); + const u8 *buffer, u32 n_bytes, int use_reserve); static void yaffs_fix_null_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size); @@ -47,9 +49,9 @@ static void yaffs_fix_null_name(struct yaffs_obj *obj, YCHAR *name, /* Function to calculate chunk and offset */ void yaffs_addr_to_chunk(struct yaffs_dev *dev, loff_t addr, - int *chunk_out, u32 *offset_out) + u32 *chunk_out, u32 *offset_out) { - int chunk; + u32 chunk; u32 offset; chunk = (u32) (addr >> dev->chunk_shift); @@ -78,7 +80,7 @@ void yaffs_addr_to_chunk(struct yaffs_dev *dev, loff_t addr, * be hellishly efficient. */ -static inline u32 calc_shifts_ceiling(u32 x) +static inline u32 yaffs_calc_shifts_ceiling(u32 x) { int extra_bits; int shifts; @@ -234,10 +236,10 @@ void yaffs_handle_chunk_error(struct yaffs_dev *dev, } } -static void yaffs_handle_chunk_wr_error(struct yaffs_dev *dev, int nand_chunk, +static void yaffs_handle_chunk_wr_error(struct yaffs_dev *dev, u32 nand_chunk, int erased_ok) { - int flash_block = nand_chunk / dev->param.chunks_per_block; + u32 flash_block = nand_chunk / dev->param.chunks_per_block; struct yaffs_block_info *bi = yaffs_get_block_info(dev, flash_block); yaffs_handle_chunk_error(dev, bi, YAFFS_ECC_RESULT_FIXED); @@ -305,9 +307,8 @@ static int yaffs_check_chunk_erased(struct yaffs_dev *dev, int nand_chunk) int retval = YAFFS_OK; u8 *data = yaffs_get_temp_buffer(dev); struct yaffs_ext_tags tags; - int result; - result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags); + yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags); if (tags.ecc_result > YAFFS_ECC_RESULT_NO_ERROR) retval = YAFFS_FAIL; @@ -333,9 +334,8 @@ static int yaffs_verify_chunk_written(struct yaffs_dev *dev, int retval = YAFFS_OK; struct yaffs_ext_tags temp_tags; u8 *buffer = yaffs_get_temp_buffer(dev); - int result; - result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags); + yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags); if (memcmp(buffer, data, dev->data_bytes_per_chunk) || temp_tags.obj_id != tags->obj_id || temp_tags.chunk_id != tags->chunk_id || @@ -364,7 +364,7 @@ int yaffs_check_alloc_available(struct yaffs_dev *dev, int n_chunks) static int yaffs_find_alloc_block(struct yaffs_dev *dev) { - int i; + u32 i; struct yaffs_block_info *bi; if (dev->n_erased_blocks < 1) { @@ -425,7 +425,7 @@ static int yaffs_alloc_chunk(struct yaffs_dev *dev, int use_reserver, return -1; } - if (dev->n_erased_blocks < dev->param.n_reserved_blocks + if (dev->n_erased_blocks < (int)dev->param.n_reserved_blocks && dev->alloc_page == 0) yaffs_trace(YAFFS_TRACE_ALLOCATE, "Allocating reserve"); @@ -443,7 +443,7 @@ static int yaffs_alloc_chunk(struct yaffs_dev *dev, int use_reserver, dev->n_free_chunks--; /* If the block is full set the state to full */ - if (dev->alloc_page >= dev->param.chunks_per_block) { + if (dev->alloc_page >= (int)dev->param.chunks_per_block) { bi->block_state = YAFFS_BLOCK_STATE_FULL; dev->alloc_block = -1; } @@ -1022,8 +1022,8 @@ struct yaffs_tnode *yaffs_add_find_tnode_0(struct yaffs_dev *dev, return tn; } -static int yaffs_tags_match(const struct yaffs_ext_tags *tags, int obj_id, - int chunk_obj) +static int yaffs_tags_match(const struct yaffs_ext_tags *tags, u32 obj_id, + u32 chunk_obj) { return (tags->chunk_id == chunk_obj && tags->obj_id == obj_id && @@ -1031,11 +1031,11 @@ static int yaffs_tags_match(const struct yaffs_ext_tags *tags, int obj_id, } -static int yaffs_find_chunk_in_group(struct yaffs_dev *dev, int the_chunk, - struct yaffs_ext_tags *tags, int obj_id, - int inode_chunk) +static int yaffs_find_chunk_in_group(struct yaffs_dev *dev, u32 the_chunk, + struct yaffs_ext_tags *tags, u32 obj_id, + u32 inode_chunk) { - int j; + u32 j; for (j = 0; the_chunk && j < dev->chunk_grp_size; j++) { if (yaffs_check_chunk_bit @@ -1526,7 +1526,7 @@ void yaffs_flush_whole_cache(struct yaffs_dev *dev, int discard) */ static struct yaffs_cache *yaffs_grab_chunk_worker(struct yaffs_dev *dev) { - int i; + u32 i; if (dev->param.n_caches > 0) { for (i = 0; i < dev->param.n_caches; i++) { @@ -1541,8 +1541,8 @@ static struct yaffs_cache *yaffs_grab_chunk_worker(struct yaffs_dev *dev) static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev) { struct yaffs_cache *cache; - int usage; - int i; + u32 usage; + u32 i; if (dev->param.n_caches < 1) return NULL; @@ -1559,7 +1559,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev) * Find the LRU cache and flush it if it is dirty. */ - usage = -1; + usage = YAFFS_MAX_CACHE_USAGE + 100; /* Silly high number */ cache = NULL; for (i = 0; i < dev->param.n_caches; i++) { @@ -1586,7 +1586,7 @@ static struct yaffs_cache *yaffs_find_chunk_cache(const struct yaffs_obj *obj, int chunk_id) { struct yaffs_dev *dev = obj->my_dev; - int i; + u32 i; if (dev->param.n_caches < 1) return NULL; @@ -1606,13 +1606,12 @@ static struct yaffs_cache *yaffs_find_chunk_cache(const struct yaffs_obj *obj, static void yaffs_use_cache(struct yaffs_dev *dev, struct yaffs_cache *cache, int is_write) { - int i; - if (dev->param.n_caches < 1) return; - if (dev->cache_last_use < 0 || - dev->cache_last_use > 100000000) { + if (dev->cache_last_use > YAFFS_MAX_CACHE_USAGE) { + u32 i; + /* Reset the cache usages */ for (i = 1; i < dev->param.n_caches; i++) dev->cache[i].last_use = 0; @@ -1647,7 +1646,7 @@ static void yaffs_invalidate_chunk_cache(struct yaffs_obj *object, int chunk_id) */ static void yaffs_invalidate_whole_cache(struct yaffs_obj *in) { - int i; + u32 i; struct yaffs_dev *dev = in->my_dev; if (dev->param.n_caches > 0) { @@ -2368,12 +2367,11 @@ alloc_error: return YAFFS_FAIL; } - -void yaffs_block_became_dirty(struct yaffs_dev *dev, int block_no) +void yaffs_block_became_dirty(struct yaffs_dev *dev, u32 block_no) { struct yaffs_block_info *bi = yaffs_get_block_info(dev, block_no); int erased_ok = 0; - int i; + u32 i; /* If the block is still healthy erase it and mark as clean. * If the block has had a data failure, then retire it. @@ -2596,7 +2594,7 @@ static int yaffs_gc_block(struct yaffs_dev *dev, int block, int whole_block) { int old_chunk; int ret_val = YAFFS_OK; - int i; + u32 i; int is_checkpt_block; int max_copies; int chunks_before = yaffs_get_erased_chunks(dev); @@ -2701,13 +2699,13 @@ static int yaffs_gc_block(struct yaffs_dev *dev, int block, int whole_block) static unsigned yaffs_find_gc_block(struct yaffs_dev *dev, int aggressive, int background) { - int i; - int iterations; + u32 i; + u32 iterations; unsigned selected = 0; int prioritised = 0; int prioritised_exist = 0; struct yaffs_block_info *bi; - int threshold; + u32 threshold; /* First let's see if we need to grab a prioritised block */ if (dev->has_pending_prioritised_gc && !aggressive) { @@ -2748,14 +2746,14 @@ static unsigned yaffs_find_gc_block(struct yaffs_dev *dev, */ if (!selected) { - int pages_used; - int n_blocks = + u32 pages_used; + u32 n_blocks = dev->internal_end_block - dev->internal_start_block + 1; if (aggressive) { threshold = dev->param.chunks_per_block; iterations = n_blocks; } else { - int max_threshold; + u32 max_threshold; if (background) max_threshold = dev->param.chunks_per_block / 2; @@ -2941,14 +2939,14 @@ static int yaffs_check_gc(struct yaffs_dev *dev, int background) gc_ok = yaffs_gc_block(dev, dev->gc_block, aggressive); } - if (dev->n_erased_blocks < (dev->param.n_reserved_blocks) && + if (dev->n_erased_blocks < (int)dev->param.n_reserved_blocks && dev->gc_block > 0) { yaffs_trace(YAFFS_TRACE_GC, "yaffs: GC !!!no reclaim!!! n_erased_blocks %d after try %d block %d", dev->n_erased_blocks, max_tries, dev->gc_block); } - } while ((dev->n_erased_blocks < dev->param.n_reserved_blocks) && + } while ((dev->n_erased_blocks < (int)dev->param.n_reserved_blocks) && (dev->gc_block > 0) && (max_tries < 2)); return aggressive ? gc_ok : YAFFS_OK; @@ -3048,7 +3046,7 @@ void yaffs_chunk_del(struct yaffs_dev *dev, int chunk_id, int mark_flash, } static int yaffs_wr_data_obj(struct yaffs_obj *in, int inode_chunk, - const u8 *buffer, int n_bytes, int use_reserve) + const u8 *buffer, u32 n_bytes, int use_reserve) { /* Find old chunk Need to do this to get serial number * Write new one and patch into tree. @@ -3083,7 +3081,7 @@ static int yaffs_wr_data_obj(struct yaffs_obj *in, int inode_chunk, if (n_bytes < 1 || n_bytes > dev->param.total_bytes_per_chunk) { yaffs_trace(YAFFS_TRACE_ERROR, - "Writing %d bytes to chunk!!!!!!!!!", + "Writing %u bytes to chunk!!!!!!!!!", n_bytes); BUG(); } @@ -3229,8 +3227,6 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in) struct yaffs_obj_hdr *oh; struct yaffs_dev *dev; struct yaffs_ext_tags tags; - int result; - int alloc_failed = 0; if (!in || !in->lazy_loaded || in->hdr_chunk < 1) return; @@ -3239,7 +3235,7 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in) in->lazy_loaded = 0; buf = yaffs_get_temp_buffer(dev); - result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags); + yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags); oh = (struct yaffs_obj_hdr *)buf; in->yst_mode = oh->yst_mode; @@ -3249,8 +3245,6 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in) if (in->variant_type == YAFFS_OBJECT_TYPE_SYMLINK) { in->variant.symlink_variant.alias = yaffs_clone_str(oh->alias); - if (!in->variant.symlink_variant.alias) - alloc_failed = 1; /* Not returned */ } yaffs_release_temp_buffer(dev, buf); } @@ -3266,7 +3260,6 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force, struct yaffs_dev *dev = in->my_dev; int prev_chunk_id; int ret_val = 0; - int result = 0; int new_chunk_id; struct yaffs_ext_tags new_tags; struct yaffs_ext_tags old_tags; @@ -3290,7 +3283,7 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force, prev_chunk_id = in->hdr_chunk; if (prev_chunk_id > 0) { - result = yaffs_rd_chunk_tags_nand(dev, prev_chunk_id, + yaffs_rd_chunk_tags_nand(dev, prev_chunk_id, buffer, &old_tags); yaffs_verify_oh(in, oh, &old_tags, 0); @@ -3413,13 +3406,13 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force, * Curve-balls: the first chunk might also be the last chunk. */ -int yaffs_file_rd(struct yaffs_obj *in, u8 * buffer, loff_t offset, int n_bytes) +int yaffs_file_rd(struct yaffs_obj *in, u8 * buffer, loff_t offset, u32 n_bytes) { - int chunk; + u32 chunk; u32 start; - int n_copy; - int n = n_bytes; - int n_done = 0; + u32 n_copy; + u32 n = n_bytes; + u32 n_done = 0; struct yaffs_cache *cache; struct yaffs_dev *dev; @@ -3489,19 +3482,19 @@ int yaffs_file_rd(struct yaffs_obj *in, u8 * buffer, loff_t offset, int n_bytes) buffer += n_copy; n_done += n_copy; } - return n_done; + return (int)n_done; } int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset, - int n_bytes, int write_through) + u32 n_bytes, int write_through) { - int chunk; + u32 chunk; u32 start; - int n_copy; - int n = n_bytes; - int n_done = 0; - int n_writeback; + u32 n_copy; + u32 n = n_bytes; + u32 n_done = 0; + u32 n_writeback; loff_t start_write = offset; int chunk_written = 0; u32 n_bytes_read; @@ -3517,8 +3510,8 @@ int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset, dev->data_bytes_per_chunk + start != offset || start >= dev->data_bytes_per_chunk) { yaffs_trace(YAFFS_TRACE_ERROR, - "AddrToChunk of offset %lld gives chunk %d start %d", - offset, chunk, start); + "addr_to_chunk() of offset %lld gives chunk %u start %u", + (long long int)offset, chunk, start); } chunk++; /* File pos to chunk in file offset */ @@ -3549,11 +3542,10 @@ int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset, n_bytes_read = dev->data_bytes_per_chunk; n_writeback = - (n_bytes_read > - (start + n)) ? n_bytes_read : (start + n); + (n_bytes_read > (start + n)) ? + n_bytes_read : (start + n); - if (n_writeback < 0 || - n_writeback > dev->data_bytes_per_chunk) + if (n_writeback > dev->data_bytes_per_chunk) BUG(); } else { @@ -3666,7 +3658,7 @@ int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset, } int yaffs_wr_file(struct yaffs_obj *in, const u8 *buffer, loff_t offset, - int n_bytes, int write_through) + u32 n_bytes, int write_through) { yaffs2_handle_hole(in, offset); return yaffs_do_file_wr(in, buffer, offset, n_bytes, write_through); @@ -3679,11 +3671,11 @@ static void yaffs_prune_chunks(struct yaffs_obj *in, loff_t new_size) struct yaffs_dev *dev = in->my_dev; loff_t old_size = in->variant.file_variant.file_size; - int i; + u32 i; int chunk_id; u32 dummy; - int last_del; - int start_del; + u32 last_del; + u32 start_del; if (old_size > 0) yaffs_addr_to_chunk(dev, old_size - 1, &last_del, &dummy); @@ -3709,9 +3701,9 @@ static void yaffs_prune_chunks(struct yaffs_obj *in, loff_t new_size) if (chunk_id < 1) continue; - if (chunk_id < + if ((u32)chunk_id < (dev->internal_start_block * dev->param.chunks_per_block) || - chunk_id >= + (u32)chunk_id >= ((dev->internal_end_block + 1) * dev->param.chunks_per_block)) { yaffs_trace(YAFFS_TRACE_ALWAYS, @@ -3726,7 +3718,7 @@ static void yaffs_prune_chunks(struct yaffs_obj *in, loff_t new_size) void yaffs_resize_file_down(struct yaffs_obj *obj, loff_t new_size) { - int new_full; + u32 new_full; u32 new_partial; struct yaffs_dev *dev = obj->my_dev; @@ -4186,7 +4178,7 @@ int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR *old_name, /*----------------------- Initialisation Scanning ---------------------- */ -void yaffs_handle_shadowed_obj(struct yaffs_dev *dev, int obj_id, +void yaffs_handle_shadowed_obj(struct yaffs_dev *dev, u32 obj_id, int backward_scanning) { struct yaffs_obj *obj; @@ -4494,18 +4486,17 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size) } else if (obj->short_name[0]) { strcpy(name, obj->short_name); } else if (obj->hdr_chunk > 0) { - int result; u8 *buffer = yaffs_get_temp_buffer(obj->my_dev); struct yaffs_obj_hdr *oh = (struct yaffs_obj_hdr *)buffer; memset(buffer, 0, obj->my_dev->data_bytes_per_chunk); - if (obj->hdr_chunk > 0) { - result = yaffs_rd_chunk_tags_nand(obj->my_dev, + if (obj->hdr_chunk > 0) + yaffs_rd_chunk_tags_nand(obj->my_dev, obj->hdr_chunk, buffer, NULL); - } + yaffs_load_name_from_oh(obj->my_dev, name, oh->name, buffer_size); @@ -4741,7 +4732,7 @@ int yaffs_guts_ll_init(struct yaffs_dev *dev) int yaffs_guts_format_dev(struct yaffs_dev *dev) { - int i; + u32 i; enum yaffs_block_state state; u32 dummy; @@ -4765,7 +4756,7 @@ int yaffs_guts_initialise(struct yaffs_dev *dev) { int init_failed = 0; unsigned x; - int bits; + unsigned bits; if(yaffs_guts_ll_init(dev) != YAFFS_OK) return YAFFS_FAIL; @@ -4797,7 +4788,7 @@ int yaffs_guts_initialise(struct yaffs_dev *dev) x = dev->param.chunks_per_block * (dev->internal_end_block + 1); - bits = calc_shifts_ceiling(x); + bits = yaffs_calc_shifts_ceiling(x); /* Set up tnode width if wide tnodes are enabled. */ if (!dev->param.wide_tnodes_disabled) { @@ -4823,7 +4814,7 @@ int yaffs_guts_initialise(struct yaffs_dev *dev) if (bits <= dev->tnode_width) dev->chunk_grp_bits = 0; else - dev->chunk_grp_bits = (u16)(bits - dev->tnode_width); + dev->chunk_grp_bits = bits - dev->tnode_width; dev->tnode_size = (dev->tnode_width * YAFFS_NTNODES_LEVEL0) / 8; if (dev->tnode_size < sizeof(struct yaffs_tnode)) @@ -4875,7 +4866,7 @@ int yaffs_guts_initialise(struct yaffs_dev *dev) dev->gc_cleanup_list = NULL; if (!init_failed && dev->param.n_caches > 0) { - int i; + u32 i; void *buf; int cache_bytes = dev->param.n_caches * sizeof(struct yaffs_cache); @@ -5010,7 +5001,7 @@ int yaffs_guts_initialise(struct yaffs_dev *dev) void yaffs_deinitialise(struct yaffs_dev *dev) { if (dev->is_mounted) { - int i; + u32 i; yaffs_deinit_blocks(dev); yaffs_deinit_tnodes_and_objs(dev); @@ -5040,8 +5031,8 @@ void yaffs_deinitialise(struct yaffs_dev *dev) int yaffs_count_free_chunks(struct yaffs_dev *dev) { - int n_free = 0; - int b; + u32 n_free = 0; + u32 b; struct yaffs_block_info *blk; blk = dev->block_info; @@ -5060,7 +5051,7 @@ int yaffs_count_free_chunks(struct yaffs_dev *dev) } blk++; } - return n_free; + return (int)n_free; } int yaffs_get_n_free_chunks(struct yaffs_dev *dev) @@ -5069,7 +5060,7 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev) int n_free; int n_dirty_caches; int blocks_for_checkpt; - int i; + u32 i; n_free = dev->n_free_chunks; n_free += dev->n_deleted_files; @@ -5125,7 +5116,7 @@ loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh) void yaffs_count_blocks_by_state(struct yaffs_dev *dev, int bs[10]) { - int i; + u32 i; struct yaffs_block_info *bi; int s; diff --git a/yaffs_guts.h b/yaffs_guts.h index 397aae8..53d9b42 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -131,7 +131,7 @@ struct yaffs_cache { struct yaffs_obj *object; int chunk_id; - int last_use; + u32 last_use; int dirty; int n_bytes; /* Only valid if the cache is dirty */ int locked; /* Can't push out or flush while locked. */ @@ -181,7 +181,7 @@ enum yaffs_obj_type { struct yaffs_ext_tags { unsigned chunk_used; /* Status of the chunk: used or unused */ - unsigned obj_id; /* If 0 this is not used */ + u32 obj_id; /* If 0 this is not used */ unsigned chunk_id; /* If 0 this is a header, else a data chunk */ unsigned n_bytes; /* Only valid for data chunks */ @@ -314,7 +314,7 @@ struct yaffs_obj_hdr { enum yaffs_obj_type type; /* Apply to everything */ - int parent_obj_id; + u32 parent_obj_id; u16 sum_no_longer_used; /* checksum of name. No longer used */ YCHAR name[YAFFS_MAX_NAME_LENGTH + 1]; @@ -527,14 +527,14 @@ struct yaffs_param { int inband_tags; /* Use unband tags */ u32 total_bytes_per_chunk; /* Should be >= 512, does not need to be a power of 2 */ - int chunks_per_block; /* does not need to be a power of 2 */ - int spare_bytes_per_chunk; /* spare area size */ - int start_block; /* Start block we're allowed to use */ - int end_block; /* End block we're allowed to use */ - int n_reserved_blocks; /* Tuneable so that we can reduce + u32 chunks_per_block; /* does not need to be a power of 2 */ + u32 spare_bytes_per_chunk; /* spare area size */ + u32 start_block; /* Start block we're allowed to use */ + u32 end_block; /* End block we're allowed to use */ + u32 n_reserved_blocks; /* Tuneable so that we can reduce * reserved blocks on NOR and RAM. */ - int n_caches; /* If <= 0, then short op caching is disabled, + u32 n_caches; /* If <= 0, then short op caching is disabled, * else the number of short op caches. */ int cache_bypass_aligned; /* If non-zero then bypass the cache for @@ -559,7 +559,7 @@ struct yaffs_param { int enable_xattr; /* Enable xattribs */ - int max_objects; /* + u32 max_objects; /* * Set to limit the number of objects created. * 0 = no limit. */ @@ -640,13 +640,13 @@ struct yaffs_dev { int ll_init; /* Runtime parameters. Set up by YAFFS. */ - int data_bytes_per_chunk; + u32 data_bytes_per_chunk; /* Non-wide tnode stuff */ - u16 chunk_grp_bits; /* Number of bits that need to be resolved if + u32 chunk_grp_bits; /* Number of bits that need to be resolved if * the tnodes are not wide enough. */ - u16 chunk_grp_size; /* == 2^^chunk_grp_bits */ + u32 chunk_grp_size; /* == 2^^chunk_grp_bits */ /* Stuff to support wide tnodes */ u32 tnode_width; @@ -663,22 +663,22 @@ struct yaffs_dev { int is_checkpointed; /* Stuff to support block offsetting to support start block zero */ - int internal_start_block; - int internal_end_block; + u32 internal_start_block; + u32 internal_end_block; int block_offset; int chunk_offset; /* Runtime checkpointing stuff */ - int checkpt_page_seq; /* running sequence number of checkpt pages */ - int checkpt_byte_count; - int checkpt_byte_offs; + u32 checkpt_page_seq; /* running sequence number of checkpt pages */ + u32 checkpt_byte_count; + u32 checkpt_byte_offs; u8 *checkpt_buffer; int checkpt_open_write; int blocks_in_checkpt; - int checkpt_cur_chunk; - int checkpt_cur_block; - int checkpt_next_block; - int *checkpt_block_list; + u32 checkpt_cur_chunk; + u32 checkpt_cur_block; + u32 checkpt_next_block; + u32 *checkpt_block_list; int checkpt_max_blocks; u32 checkpt_sum; u32 checkpt_xor; @@ -691,14 +691,14 @@ struct yaffs_dev { u8 *chunk_bits; /* bitmap of chunks in use */ u8 block_info_alt:1; /* allocated using alternative alloc */ u8 chunk_bits_alt:1; /* allocated using alternative alloc */ - int chunk_bit_stride; /* Number of bytes of chunk_bits per block. + u32 chunk_bit_stride; /* Number of bytes of chunk_bits per block. * Must be consistent with chunks_per_block. */ int n_erased_blocks; int alloc_block; /* Current block being allocated off */ - u32 alloc_page; - int alloc_block_finder; /* Used to search for next allocation block */ + int alloc_page; + u32 alloc_block_finder; /* Used to search for next allocation block */ /* Object and Tnode memory management */ void *allocator; @@ -736,7 +736,7 @@ struct yaffs_dev { int doing_buffered_block_rewrite; struct yaffs_cache *cache; - int cache_last_use; + u32 cache_last_use; /* Stuff for background deletion and unlinked files. */ struct yaffs_obj *unlinked_dir; /* Directory where unlinked and deleted @@ -829,7 +829,7 @@ struct yaffs_checkpt_validity { }; struct yaffs_shadow_fixer { - int obj_id; + u32 obj_id; int shadowed_id; struct yaffs_shadow_fixer *next; }; @@ -868,9 +868,9 @@ int yaffs_get_obj_link_count(struct yaffs_obj *obj); /* File operations */ int yaffs_file_rd(struct yaffs_obj *obj, u8 * buffer, loff_t offset, - int n_bytes); + u32 n_bytes); int yaffs_wr_file(struct yaffs_obj *obj, const u8 * buffer, loff_t offset, - int n_bytes, int write_trhrough); + u32 n_bytes, int write_trhrough); int yaffs_resize_file(struct yaffs_obj *obj, loff_t new_size); struct yaffs_obj *yaffs_create_file(struct yaffs_obj *parent, @@ -958,11 +958,11 @@ void yaffs_set_obj_name_from_oh(struct yaffs_obj *obj, void yaffs_add_obj_to_dir(struct yaffs_obj *directory, struct yaffs_obj *obj); YCHAR *yaffs_clone_str(const YCHAR *str); void yaffs_link_fixup(struct yaffs_dev *dev, struct list_head *hard_list); -void yaffs_block_became_dirty(struct yaffs_dev *dev, int block_no); +void yaffs_block_became_dirty(struct yaffs_dev *dev, u32 block_no); int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force, int is_shrink, int shadows, struct yaffs_xattr_mod *xop); -void yaffs_handle_shadowed_obj(struct yaffs_dev *dev, int obj_id, +void yaffs_handle_shadowed_obj(struct yaffs_dev *dev, u32 obj_id, int backward_scanning); int yaffs_check_alloc_available(struct yaffs_dev *dev, int n_chunks); struct yaffs_tnode *yaffs_get_tnode(struct yaffs_dev *dev); @@ -972,7 +972,7 @@ struct yaffs_tnode *yaffs_add_find_tnode_0(struct yaffs_dev *dev, struct yaffs_tnode *passed_tn); int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset, - int n_bytes, int write_trhrough); + u32 n_bytes, int write_trhrough); void yaffs_resize_file_down(struct yaffs_obj *obj, loff_t new_size); void yaffs_skip_rest_of_block(struct yaffs_dev *dev); @@ -990,7 +990,7 @@ int yaffs_is_non_empty_dir(struct yaffs_obj *obj); int yaffs_guts_format_dev(struct yaffs_dev *dev); void yaffs_addr_to_chunk(struct yaffs_dev *dev, loff_t addr, - int *chunk_out, u32 *offset_out); + u32 *chunk_out, u32 *offset_out); /* * Marshalling functions to get loff_t file sizes into aand out of * object headers. @@ -1009,4 +1009,8 @@ void yaffs_count_blocks_by_state(struct yaffs_dev *dev, int bs[10]); int yaffs_find_chunk_in_file(struct yaffs_obj *in, int inode_chunk, struct yaffs_ext_tags *tags); +/* Global to control max write attempts */ +extern int yaffs_wr_attempts; + + #endif diff --git a/yaffs_nameval.c b/yaffs_nameval.c index 4bdf4ed..767f9e0 100644 --- a/yaffs_nameval.c +++ b/yaffs_nameval.c @@ -44,7 +44,7 @@ static int nval_find(const char *xb, int xb_size, const YCHAR *name, return pos; } pos += size; - if (pos < xb_size - sizeof(int)) + if (pos < xb_size - (int)sizeof(int)) memcpy(&size, xb + pos, sizeof(int)); else size = 0; @@ -62,7 +62,7 @@ static int nval_used(const char *xb, int xb_size) memcpy(&size, xb + pos, sizeof(int)); while (size > 0 && (size < xb_size) && (pos + size < xb_size)) { pos += size; - if (pos < xb_size - sizeof(int)) + if (pos < xb_size - (int)sizeof(int)) memcpy(&size, xb + pos, sizeof(int)); else size = 0; @@ -173,7 +173,7 @@ int nval_list(const char *xb, int xb_size, char *buf, int bsize) int filled = 0; memcpy(&size, xb + pos, sizeof(int)); - while (size > sizeof(int) && + while (size > (int)sizeof(int) && size <= xb_size && (pos + size) < xb_size && !filled) { @@ -194,7 +194,7 @@ int nval_list(const char *xb, int xb_size, char *buf, int bsize) filled = 1; } pos += size; - if (pos < xb_size - sizeof(int)) + if (pos < xb_size - (int)sizeof(int)) memcpy(&size, xb + pos, sizeof(int)); else size = 0; diff --git a/yaffs_summary.c b/yaffs_summary.c index e9e1b5d..07fa526 100644 --- a/yaffs_summary.c +++ b/yaffs_summary.c @@ -183,7 +183,7 @@ int yaffs_summary_read(struct yaffs_dev *dev, u8 *buffer; u8 *sum_buffer = (u8 *)st; int n_bytes; - int chunk_id; + u32 chunk_id; int chunk_in_nand; int chunk_in_block; int result; @@ -292,7 +292,7 @@ int yaffs_summary_fetch(struct yaffs_dev *dev, void yaffs_summary_gc(struct yaffs_dev *dev, int blk) { struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk); - int i; + u32 i; if (!bi->has_summary) return; diff --git a/yaffs_tagsmarshall.c b/yaffs_tagsmarshall.c index a5989fa..98ae10d 100644 --- a/yaffs_tagsmarshall.c +++ b/yaffs_tagsmarshall.c @@ -124,7 +124,7 @@ static int yaffs_tags_marshall_read(struct yaffs_dev *dev, dev->n_ecc_fixed++; } - if (ecc_result < YAFFS_ECC_RESULT_UNFIXED) + if (retval == YAFFS_OK && ecc_result < YAFFS_ECC_RESULT_UNFIXED) return YAFFS_OK; else return YAFFS_FAIL; diff --git a/yaffs_trace.h b/yaffs_trace.h index fd26054..46fed85 100644 --- a/yaffs_trace.h +++ b/yaffs_trace.h @@ -17,7 +17,6 @@ #define __YTRACE_H__ extern unsigned int yaffs_trace_mask; -extern unsigned int yaffs_wr_attempts; /* * Tracing flags. diff --git a/yaffs_verify.c b/yaffs_verify.c index e8f2f0a..c7ae2c1 100644 --- a/yaffs_verify.c +++ b/yaffs_verify.c @@ -77,10 +77,10 @@ void yaffs_verify_blk(struct yaffs_dev *dev, struct yaffs_block_info *bi, int n) actually_used = bi->pages_in_use - bi->soft_del_pages; if (bi->pages_in_use < 0 || - bi->pages_in_use > dev->param.chunks_per_block || + bi->pages_in_use > (int)dev->param.chunks_per_block || bi->soft_del_pages < 0 || - bi->soft_del_pages > dev->param.chunks_per_block || - actually_used < 0 || actually_used > dev->param.chunks_per_block) + bi->soft_del_pages > (int)dev->param.chunks_per_block || + actually_used < 0 || actually_used > (int)dev->param.chunks_per_block) yaffs_trace(YAFFS_TRACE_VERIFY, "Block %d has illegal values pages_in_used %d soft_del_pages %d", n, bi->pages_in_use, bi->soft_del_pages); @@ -110,7 +110,7 @@ void yaffs_verify_collected_blk(struct yaffs_dev *dev, void yaffs_verify_blocks(struct yaffs_dev *dev) { - int i; + u32 i; int state_count[YAFFS_NUMBER_OF_BLOCK_STATES]; int illegal_states = 0; @@ -224,8 +224,7 @@ void yaffs_verify_file(struct yaffs_obj *obj) { u32 x; int required_depth; - int actual_depth; - int last_chunk; + u32 last_chunk; u32 offset_in_chunk; u32 the_chunk; @@ -256,8 +255,6 @@ void yaffs_verify_file(struct yaffs_obj *obj) required_depth++; } - actual_depth = obj->variant.file_variant.top_level; - /* Check that the chunks in the tnode tree are all correct. * We do this by scanning through the tnode tree and * checking the tags for every chunk match. diff --git a/yaffs_yaffs1.c b/yaffs_yaffs1.c index d277e20..e0c0ee5 100644 --- a/yaffs_yaffs1.c +++ b/yaffs_yaffs1.c @@ -22,10 +22,9 @@ int yaffs1_scan(struct yaffs_dev *dev) { struct yaffs_ext_tags tags; - int blk; - int result; + u32 blk; int chunk; - int c; + u32 c; int deleted; enum yaffs_block_state state; LIST_HEAD(hard_list); @@ -95,7 +94,7 @@ int yaffs1_scan(struct yaffs_dev *dev) /* Read the tags and decide what to do */ chunk = blk * dev->param.chunks_per_block + c; - result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL, + yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags); /* Let's have a good look at this chunk... */ @@ -181,7 +180,7 @@ int yaffs1_scan(struct yaffs_dev *dev) yaffs_set_chunk_bit(dev, blk, c); bi->pages_in_use++; - result = yaffs_rd_chunk_tags_nand(dev, chunk, + yaffs_rd_chunk_tags_nand(dev, chunk, chunk_data, NULL); diff --git a/yaffs_yaffs2.c b/yaffs_yaffs2.c index 8c31a66..4bbc769 100644 --- a/yaffs_yaffs2.c +++ b/yaffs_yaffs2.c @@ -41,7 +41,7 @@ */ void yaffs_calc_oldest_dirty_seq(struct yaffs_dev *dev) { - int i; + u32 i; unsigned seq; unsigned block_no = 0; struct yaffs_block_info *b; @@ -55,7 +55,7 @@ void yaffs_calc_oldest_dirty_seq(struct yaffs_dev *dev) for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) { if (b->block_state == YAFFS_BLOCK_STATE_FULL && (b->pages_in_use - b->soft_del_pages) < - dev->param.chunks_per_block && + (int)dev->param.chunks_per_block && b->seq_number < seq) { seq = b->seq_number; block_no = i; @@ -309,7 +309,7 @@ static void yaffs_checkpt_dev_to_dev(struct yaffs_dev *dev, static int yaffs2_wr_checkpt_dev(struct yaffs_dev *dev) { struct yaffs_checkpt_dev cp; - u32 n_bytes; + int n_bytes; u32 n_blocks = dev->internal_end_block - dev->internal_start_block + 1; int ok; @@ -337,7 +337,7 @@ static int yaffs2_wr_checkpt_dev(struct yaffs_dev *dev) static int yaffs2_rd_checkpt_dev(struct yaffs_dev *dev) { struct yaffs_checkpt_dev cp; - u32 n_bytes; + int n_bytes; u32 n_blocks = (dev->internal_end_block - dev->internal_start_block + 1); int ok; @@ -473,7 +473,7 @@ static int yaffs2_checkpt_tnode_worker(struct yaffs_obj *in, sizeof(base_offset)); if (ok) ok = (yaffs2_checkpt_wr(dev, tn, dev->tnode_size) == - dev->tnode_size); + (int)dev->tnode_size); return ok; } @@ -516,7 +516,7 @@ static int yaffs2_rd_checkpt_tnodes(struct yaffs_obj *obj) tn = yaffs_get_tnode(dev); if (tn) ok = (yaffs2_checkpt_rd(dev, tn, dev->tnode_size) == - dev->tnode_size); + (int)dev->tnode_size); else ok = 0; @@ -606,7 +606,7 @@ static int yaffs2_rd_checkpt_objs(struct yaffs_dev *dev) cp.obj_id, cp.parent_id, cp.variant_type, cp.hdr_chunk); - if (ok && cp.obj_id == ~0) { + if (ok && cp.obj_id == (u32)(~0)) { done = 1; } else if (ok) { obj = @@ -881,7 +881,7 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size) while (increase > 0 && small_increase_ok) { this_write = increase; - if (this_write > dev->data_bytes_per_chunk) + if (this_write > (int)dev->data_bytes_per_chunk) this_write = dev->data_bytes_per_chunk; written = yaffs_do_file_wr(obj, local_buffer, pos, this_write, @@ -946,7 +946,6 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, int is_shrink; int is_unlinked; struct yaffs_ext_tags tags; - int result; int alloc_failed = 0; int chunk = blk * dev->param.chunks_per_block + chunk_in_block; struct yaffs_file_var *file_var; @@ -954,12 +953,12 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, struct yaffs_symlink_var *sl_var; if (summary_available) { - result = yaffs_summary_fetch(dev, &tags, chunk_in_block); + yaffs_summary_fetch(dev, &tags, chunk_in_block); tags.seq_number = bi->seq_number; } if (!summary_available || tags.obj_id == 0) { - result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags); + yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags); dev->tags_used++; } else { dev->summary_used++; @@ -1114,7 +1113,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, * invalid data until needed. */ - result = yaffs_rd_chunk_tags_nand(dev, + yaffs_rd_chunk_tags_nand(dev, chunk, chunk_data, NULL); @@ -1344,14 +1343,13 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, int yaffs2_scan_backwards(struct yaffs_dev *dev) { - int blk; + u32 blk; int block_iter; int start_iter; int end_iter; int n_to_scan = 0; enum yaffs_block_state state; int c; - int deleted; LIST_HEAD(hard_list); struct yaffs_block_info *bi; u32 seq_number; @@ -1469,7 +1467,6 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev) /* get the block to scan in the correct order */ blk = block_index[block_iter].block; bi = yaffs_get_block_info(dev, blk); - deleted = 0; summary_available = yaffs_summary_read(dev, dev->sum_tags, blk);