Compilation clean up
authorCharles Manning <cdhmanning@gmail.com>
Wed, 6 Jul 2016 21:30:35 +0000 (09:30 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 7 Jul 2016 04:41:31 +0000 (16:41 +1200)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
30 files changed:
direct/test-framework/FrameworkRules.mk
direct/test-framework/nanddrv.c
direct/test-framework/nandsim.c
direct/test-framework/tests/nor_stress.c
direct/test-framework/tests/yaffs_fsx.c
direct/test-framework/yaffs_fileem.c
direct/test-framework/yaffs_fileem2k.c
direct/test-framework/yaffs_m18_drv.c
direct/test-framework/yaffs_nand_drv.c
direct/test-framework/yaffs_nandsim_file.c
direct/test-framework/yaffs_nandsim_file.h
direct/test-framework/yaffs_nor_drv.c
direct/test-framework/yaffs_osglue.c
direct/test-framework/yaffs_ramdisk.c
direct/test-framework/yaffs_ramem2k.c
direct/test-framework/yaffscfg2k.c
direct/yaffs_attribs.c
direct/yaffsfs.c
yaffs_bitmap.c
yaffs_checkptrw.c
yaffs_endian.c
yaffs_getblockinfo.h
yaffs_guts.c
yaffs_guts.h
yaffs_nameval.c
yaffs_summary.c
yaffs_tagsmarshall.c
yaffs_verify.c
yaffs_yaffs1.c
yaffs_yaffs2.c

index e33cde579ec9d72aa85c24dfe3cef049dd2444d2..e4006598900d13eae869415148347b4c215df0cb 100644 (file)
@@ -19,7 +19,7 @@
 
 CFLAGS =      -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_YAFFS2  -DCONFIG_YAFFS_DEFINES_TYPES
 CFLAGS +=     -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
-CFLAGS +=    -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing
+CFLAGS +=    -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing -Werror
 #CFLAGS +=    -fno-strict-aliasing
 CFLAGS +=    -O0
 CFLAGS +=    -Wextra -Wpointer-arith
index 5fb05c0a2f46f619c22998a43a8dbd99a419d0b6..2008ecf89fe60b3f835a1c1dfa3ef429980ffca3 100644 (file)
@@ -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) {
index 9c8a6fe26d816f8eeb456e6eaae0c031dd95a4b6..ded465b461bb864744378e621cd40b1c2f3f0955 100644 (file)
@@ -94,6 +94,8 @@ static void check_last(struct nandsim_private *ns,
 
 static void idle(struct nandsim_private *ns, int line)
 {
+       (void) line;
+
        ns->read_offset = -1;
        ns->write_offset = -1;
        ns->addr_offset = -1;
@@ -175,27 +177,35 @@ 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)
 {
+       (void) ns;
+       (void) line;
 }
 
 static void end_cmd(struct nandsim_private *ns, int line)
 {
+       (void) line;
+
        ns->last_cmd_byte = 0xff;
 }
 
 static void set_busy(struct nandsim_private *ns, int cycles, int line)
 {
+       (void) line;
+
        ns->busy_count = cycles;
 }
 
@@ -380,11 +390,13 @@ static void read_status(struct nandsim_private *ns)
 
 static void read_id(struct nandsim_private *ns)
 {
+       (void) ns;
 }
 
 
 static void unsupported(struct nandsim_private *ns)
 {
+       (void) ns;
 }
 
 static void nandsim_cl_write(struct nandsim_private *ns, unsigned char val)
@@ -447,7 +459,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 +473,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)
 {
index adf1b29d362e1638927e286b329c7a99d3dd892a..93a9a8e33bfe5ef98850c2cc9cd6af683202db7f 100644 (file)
@@ -19,6 +19,7 @@
 #include "yaffs_fsx.h"
 
 #include <stdio.h>
+#include <unistd.h>
 
 
 extern int fuzz_test;
index aa234cd9403e8d559dcf0a402aedd6e2890f0bf8..88fe99fc5e668be4fd24ce498a9cfde0879cd8b4 100644 (file)
  *      yaffs direct. Seek out the original fsx.c if you want to do anything
  *     else.
  *
- *     
+ *
  *
  *     File:   fsx.c
  *     Author: Avadis Tevanian, Jr.
  *
- *     File system exerciser. 
+ *     File system exerciser.
  *
  *     Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com
  *
@@ -120,7 +120,7 @@ char                state[256];
 unsigned long  testcalls = 0;          /* calls to function "test" */
 
 unsigned long  simulatedopcount = 0;   /* -b flag */
-int    closeprob = 0;                  /* -c flag */
+unsigned       closeprob = 0;          /* -c flag */
 int    debug = 0;                      /* -d flag */
 unsigned long  debugstart = 0;         /* -D flag */
 unsigned long  maxfilelen = 256 * 1024;        /* -l flag */
@@ -243,7 +243,7 @@ logdump(void)
                lp = &oplog[i];
                if ((closeopen = lp->operation < 0))
                        lp->operation = ~ lp->operation;
-                       
+
                switch (lp->operation) {
                case OP_MAPREAD:
                        prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)",
@@ -333,7 +333,7 @@ save_buffer(char *buffer, off_t bufferlength, int fd)
        ret = yaffs_lseek(fd, (off_t)0, SEEK_SET);
        if (ret == (off_t)-1)
                prterr("save_buffer: lseek 0");
-       
+
        byteswritten = yaffs_write(fd, buffer, (size_t)bufferlength);
        if (byteswritten != bufferlength) {
                if (byteswritten == -1)
@@ -350,7 +350,7 @@ void
 report_failure(int status)
 {
        logdump();
-       
+
        if (fsxgoodfd) {
                if (good_buf) {
                        save_buffer(good_buf, file_size, fsxgoodfd);
@@ -422,7 +422,8 @@ check_size(void)
                statbuf.st_size = -1;
        }
        size_by_seek = yaffs_lseek(fd, (off_t)0, SEEK_END);
-       if (file_size != statbuf.st_size || file_size != size_by_seek) {
+       if (file_size != statbuf.st_size ||
+          file_size != size_by_seek) {
                prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
                    (unsigned long long)file_size,
                    (unsigned long long)statbuf.st_size,
@@ -461,7 +462,7 @@ doread(unsigned offset, unsigned size)
                log4(OP_SKIPPED, OP_READ, offset, size);
                return;
        }
-       if (size + offset > file_size) {
+       if ((off_t)(size + offset) > file_size) {
                if (!quiet && testcalls > simulatedopcount)
                        prt("skipping seek/read past end of file\n");
                log4(OP_SKIPPED, OP_READ, offset, size);
@@ -488,7 +489,7 @@ doread(unsigned offset, unsigned size)
        }
        iret = yaffs_read(fd, temp_buf, size);
        if (iret != size) {
-               if (iret == -1)
+               if (iret == (unsigned)(-1))
                        prterr("doread: read");
                else
                        prt("short read: 0x%x bytes instead of 0x%x\n",
@@ -506,7 +507,7 @@ void
 gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
 {
        while (size--) {
-               good_buf[offset] = testcalls % 256; 
+               good_buf[offset] = testcalls % 256;
                if (offset % 2)
                        good_buf[offset] += original_buf[offset];
                offset++;
@@ -559,7 +560,7 @@ dowrite(unsigned offset, unsigned size)
        }
        iret = yaffs_write(fd, good_buf + offset, size);
        if (iret != size) {
-               if (iret == -1)
+               if (iret == (unsigned)(-1))
                        prterr("dowrite: write");
                else
                        prt("short write: 0x%x bytes instead of 0x%x\n",
@@ -590,7 +591,7 @@ dotruncate(unsigned size)
 
        if (testcalls <= simulatedopcount)
                return;
-       
+
        if ((progressinterval && testcalls % progressinterval == 0) ||
            (debug && (monitorstart == -1 || monitorend == -1 ||
                       size <= monitorend)))
@@ -631,7 +632,7 @@ writefileimage()
 
 void
 docloseopen(void)
-{ 
+{
        if (testcalls <= simulatedopcount)
                return;
 
@@ -668,7 +669,7 @@ yaffs_fsx_do_op(void)
        testcalls++;
 
        if (closeprob)
-               closeopen = (rv >> 3) < (1 << 28) / closeprob;
+               closeopen = (rv >> 3) < (1U << 28) / closeprob;
 
        if (debugstart > 0 && testcalls >= debugstart)
                debug = 1;
@@ -702,7 +703,7 @@ yaffs_fsx_do_op(void)
                                        offset %= file_size;
                                else
                                        offset = 0;
-                               if (offset + size > file_size)
+                               if ((ssize_t)(offset + size) > file_size)
                                        size = file_size - offset;
                                doread(offset, size);
                        }
@@ -799,7 +800,7 @@ int mounted_by_fsx = 0;
 int
 yaffs_fsx_init(const char *mount_pt)
 {
-       int     i;
+       unsigned        i;
 
        goodfile[0] = 0;
        logfile[0] = 0;
@@ -812,7 +813,7 @@ yaffs_fsx_init(const char *mount_pt)
        strcpy(mount_name,mount_pt);
        strcpy(fname,mount_name);
        strcat(fname,"/fsxdata");
-       
+
 #if 0
        signal(SIGHUP,  cleanup);
        signal(SIGINT,  cleanup);
@@ -873,7 +874,7 @@ yaffs_fsx_init(const char *mount_pt)
                ssize_t written;
 
                written = yaffs_write(fd, good_buf, (size_t)maxfilelen);
-               if (written != maxfilelen) {
+               if (written != (ssize_t)maxfilelen) {
                        if (written == -1) {
                                prterr(fname);
                                warn("main: error on write");
@@ -882,11 +883,11 @@ yaffs_fsx_init(const char *mount_pt)
                                     (unsigned)written, maxfilelen);
                        EXIT(98);
                }
-       } else 
+       } else
                check_trunc_hack();
-               
+
        printf("yaffs_fsx_init done\n");
-               
+
        return 0;
 }
 
@@ -897,9 +898,9 @@ int yaffs_fsx_complete(void)
                prterr("close");
                report_failure(99);
        }
-       
+
        yaffs_close(fsxgoodfd);
-       
+
        prt("All operations completed A-OK!\n");
 
        EXIT(0);
@@ -913,6 +914,6 @@ yaffs_fsx_main(const char *mount_pt, int numops)
        while (numops == -1 || numops--)
                yaffs_fsx_do_op();
        yaffs_fsx_complete();
-       
+
        return 0;
 }
index 96a64c61a32c1084abf9c361ececaf32351ebb9a..a791214fb891f74fe5a4e6c791d7766c3f30e548 100644 (file)
@@ -25,7 +25,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <unistd.h> 
+#include <unistd.h>
 
 
 
@@ -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,55 @@ 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) 
+
+       (void)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,27 +117,25 @@ 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,38 +145,35 @@ 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;
 
 }
 
 
 int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 {
-
        int i;
-               
+
        CheckInit(dev);
-       
+
        if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
        {
                yaffs_trace(YAFFS_TRACE_ALWAYS,
@@ -189,25 +183,26 @@ int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
        }
        else
        {
-       
+
                yflash_Page pg;
-               
+
                memset(&pg,0xff,sizeof(yflash_Page));
-               
+
                lseek(filedisk.handle, blockNumber * 32 * 528, SEEK_SET);
-               
+
                for(i = 0; i < 32; i++)
                {
                        write(filedisk.handle,&pg,528);
                }
                return YAFFS_OK;
        }
-       
+
 }
 
 int yflash_InitialiseNAND(struct yaffs_dev *dev)
 {
-       
+       (void) dev;
+
        return YAFFS_OK;
 }
 
index b9a00f1be619eb18245967fde2682dc1060c8e66..8da77dc6ff8c7990f36773267ef96f32e459c508 100644 (file)
@@ -93,7 +93,6 @@ static int nops_so_far;
 
 int ops_multiplier;
 
-
 static void yflash2_MaybePowerFail(unsigned int nand_chunk, int failPoint)
 {
 
@@ -110,12 +109,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);
@@ -277,7 +270,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,7 +285,6 @@ 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);
 
@@ -303,7 +295,6 @@ static int yflash2_EraseBlock(struct yaffs_dev *dev, int block_no)
                {
                        write(h,pg,PAGE_SIZE);
                }
-               pos = lseek(h, 0,SEEK_CUR);
 
                return YAFFS_OK;
        }
index 9a8ee49e903044d97e80ed4121e3ecdb38686cbf..da425e0c8c44b4bff236c004b9179f2785c99151 100644 (file)
@@ -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);
 
+       (void) 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 */
index 9bdcb5550f9c81304f424284d0b8a70ca9cce146..f739d1d99e5169621f9fdfe1400d7529c4059550 100644 (file)
@@ -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)
index 16e69a0c944f50aafdb6136b7116e158697795ad..fb123cc8111fadc776c99177715517d8160104ac 100644 (file)
@@ -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"
index 0960dacc6ba0d792b3c2b4b25a881ad2ad5320f2..a374bf7b1792d4b2e0e1e15d532b63b7b03e1296 100644 (file)
  * 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_NANDSIM_FILE_H__
+#define __YAFFS_NANDSIM_FILE_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);
 
index 7ac108aa2f6323392dacf4a411ea76019b68aca8..65faca1255597e4afd2eb67445a849fa5f942271 100644 (file)
@@ -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);
 
+       (void) 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 */
index e31ad222a99572c4a6c0ec5204dc0ff51decdce9..6f0afabd054435a95d5903505aad489546d91268 100644 (file)
@@ -53,6 +53,9 @@ int yaffsfs_GetLastError(void)
  */
 int yaffsfs_CheckMemRegion(const void *addr, size_t size, int write_request)
 {
+       (void) size;
+       (void) write_request;
+
        if(!addr)
                return -1;
        return 0;
@@ -91,6 +94,8 @@ static void *bg_gc_func(void *dummy)
        int result;
        int next_urgent;
 
+       (void)dummy;
+
        /* Sleep for a bit to allow start up */
        sleep(2);
 
index 3d71e5170e0190aaf7e9c8c378bebe4623b67774..12ee90cd358938e0339b52bd8bcb74d86784cf0c 100644 (file)
@@ -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,31 @@ static yramdisk_device ramdisk;
 static int  CheckInit(struct yaffs_dev *dev)
 {
        static int initialised = 0;
-       
+
        int i;
        int fail = 0;
-       //int nBlocks; 
+       //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 <ramdisk.nBlocks; i++)
        {
                ramdisk.block[i] = NULL;
        }
-       
+
        for(i=0; i <ramdisk.nBlocks && !fail; i++)
        {
                if((ramdisk.block[i] = malloc(sizeof(yramdisk_block))) == 0)
@@ -97,7 +97,7 @@ static int  CheckInit(struct yaffs_dev *dev)
                        nAllocated++;
                }
        }
-       
+
        if(fail)
        {
                for(i = 0; i < nAllocated; i++)
@@ -105,14 +105,14 @@ static int  CheckInit(struct yaffs_dev *dev)
                        kfree(ramdisk.block[i]);
                }
                kfree(ramdisk.block);
-               
+
                yaffs_trace(YAFFS_TRACE_ALWAYS,
                        "Allocation failed, could only allocate %dMB of %dMB requested.\n",
                        nAllocated/64,ramdisk.nBlocks * 528);
                return 0;
        }
-       
-       
+
+
        return 1;
 }
 
@@ -120,29 +120,29 @@ int yramdisk_wr_chunk(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const
 {
        int blk;
        int pg;
-       
+
 
        CheckInit(dev);
-       
+
        blk = nand_chunk/32;
        pg = nand_chunk%32;
-       
-       
+
+
        if(data)
        {
                memcpy(ramdisk.block[blk]->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 +152,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 +184,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 +205,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 +220,16 @@ 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. 
+       (void) dev;
+
+       //dev->use_nand_ecc = 1; // force on use_nand_ecc which gets faked.
                                                 // This saves us doing ECC checks.
-       
+
        return YAFFS_OK;
 }
 
index cfb0f4f0b5e1e827e72b97ff73a399fa5f5d89d5..11f90332cc98565c78b1e0d5e27f93edf26161fc 100644 (file)
@@ -77,6 +77,7 @@ static int sizeInMB = EM_SIZE_IN_MEG;
 
 static void nandemul_yield(int n)
 {
+       (void)n;
 #ifdef __KERNEL__
        if(n > 0) schedule_timeout(n);
 #endif
@@ -260,34 +261,9 @@ int nandemul2k_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,int nand_chunk, u
        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;
-               }
-       }
-
-       return YAFFS_OK;
-
-}
-
 int nandemul2k_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 {
-
+       (void) dev;
 
        if(blockNumber < 0 || blockNumber >= ned.nBlocks)
        {
@@ -311,6 +287,8 @@ int nandemul2k_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 
 int nandemul2k_InitialiseNAND(struct yaffs_dev *dev)
 {
+       (void) dev;
+
        CheckInit();
        return YAFFS_OK;
 }
@@ -320,6 +298,8 @@ int nandemul2k_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no)
 
        u8 *x;
 
+       (void) dev;
+
        x = &ned.block[block_no]->page[0]->data[PAGE_DATA_SIZE];
 
        memset(x,0,sizeof(struct yaffs_packed_tags2));
index b053ce46801bd47f170b6a7f7d6aa3bb4dc359e4..fc9466b300361d7c1370cd15ccc972564a15cbf1 100644 (file)
@@ -25,6 +25,7 @@
 #include "yaffs_nandemul2k.h"
 #include "yaffs_trace.h"
 #include "yaffs_osglue.h"
+#include "yaffs_nandsim_file.h"
 
 
 #include <errno.h>
index de80fe42fcd0e70f7a147707b900b55f67fcca9d..de8e451eeb8b50d17bad8a994e36690d123191b7 100644 (file)
@@ -87,22 +87,3 @@ void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c)
                obj->yst_ctime = obj->yst_atime;
 #endif
 }
-
-static Y_LOFF_T yaffs_get_file_size(struct yaffs_obj *obj)
-{
-       YCHAR *alias = NULL;
-       obj = yaffs_get_equivalent_obj(obj);
-
-       switch (obj->variant_type) {
-       case YAFFS_OBJECT_TYPE_FILE:
-               return obj->variant.file_variant.file_size;
-       case YAFFS_OBJECT_TYPE_SYMLINK:
-               alias = obj->variant.symlink_variant.alias;
-               if (!alias)
-                       return 0;
-               return yaffs_strnlen(alias, YAFFS_MAX_ALIAS_LENGTH);
-       default:
-               return 0;
-       }
-}
-
index 3cb11a92a3c4675ec4220cad03e4378625168ec1..7647444699f56d7e8cdf88cac1f01b05df511b98 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "string.h"
 
+#define YAFFS_MAX_RW_SIZE      0x70000000
 #define YAFFSFS_MAX_SYMLINK_DEREFERENCES 5
 
 #ifndef NULL
@@ -1187,7 +1188,7 @@ 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) {
+       } else if (nbyte > YAFFS_MAX_RW_SIZE) {
                yaffsfs_SetError(-EINVAL);
                totalRead = -1;
        } else {
@@ -1211,7 +1212,7 @@ 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 ||
+                   nbyte > YAFFS_MAX_RW_SIZE ||
                    endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) {
                        totalRead = -1;
                        nbyte = 0;
@@ -1220,7 +1221,7 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte,
                while (nbyte > 0) {
                        nToRead = YAFFSFS_RW_SIZE -
                            (pos & (YAFFSFS_RW_SIZE - 1));
-                       if (nToRead > nbyte)
+                       if (nToRead > (int)nbyte)
                                nToRead = nbyte;
 
                        /* Tricky bit...
@@ -1324,7 +1325,7 @@ 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 ||
+                   nbyte > YAFFS_MAX_RW_SIZE ||
                    endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) {
                        totalWritten = -1;
                        nbyte = 0;
@@ -1334,7 +1335,7 @@ static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte,
 
                        nToWrite = YAFFSFS_RW_SIZE -
                            (pos & (YAFFSFS_RW_SIZE - 1));
-                       if (nToWrite > nbyte)
+                       if (nToWrite > (int)nbyte)
                                nToWrite = nbyte;
 
                        /* Tricky bit...
@@ -1622,7 +1623,7 @@ int yaffs_fgetfl(int fd, int *flags)
 {
        struct yaffsfs_FileDes *fdp = yaffsfs_HandleToFileDes(fd);
        int retVal;
-       
+
        yaffsfs_Lock();
 
        if(!flags || !fdp) {
@@ -1637,7 +1638,7 @@ int yaffs_fgetfl(int fd, int *flags)
                        *flags = O_RDONLY;
                retVal = 0;
        }
-       
+
        yaffsfs_Unlock();
        return retVal;
 }
@@ -1790,7 +1791,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;
 
@@ -3578,7 +3579,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 = 0;
                        dsc->de.d_off = dsc->offset++;
                        yaffs_get_obj_name(dsc->nextReturn,
                                           dsc->de.d_name, NAME_MAX);
index 4440e930d6bcd802a282c79651d9c00b9643be5d..bf8cbb3defaec15beb2535755faa92834356897c 100644 (file)
@@ -19,7 +19,8 @@
 
 static inline u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk)
 {
-       if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
+       if (blk < (int)dev->internal_start_block ||
+           blk > (int)dev->internal_end_block) {
                yaffs_trace(YAFFS_TRACE_ERROR,
                        "BlockBits block %d is not valid",
                        blk);
@@ -31,8 +32,9 @@ static inline u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk)
 
 void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk)
 {
-       if (blk < dev->internal_start_block || blk > dev->internal_end_block ||
-           chunk < 0 || chunk >= dev->param.chunks_per_block) {
+       if (blk < (int)dev->internal_start_block ||
+           blk > (int)dev->internal_end_block ||
+           chunk < 0 || chunk >= (int)dev->param.chunks_per_block) {
                yaffs_trace(YAFFS_TRACE_ERROR,
                        "Chunk Id (%d:%d) invalid",
                        blk, chunk);
index 59ca34afe3ee749aff52f664bfff11d8369ab86e..c7cbda3627c1ec49f543cebdbe47f5e2068ec22d 100644 (file)
@@ -87,7 +87,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;
@@ -126,7 +126,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,
@@ -135,7 +135,7 @@ static void yaffs2_checkpt_find_erased_block(struct yaffs_dev *dev)
                blocks_avail, dev->checkpt_next_block);
 
        if (dev->checkpt_next_block >= 0 &&
-           dev->checkpt_next_block <= dev->internal_end_block &&
+           dev->checkpt_next_block <= (int)dev->internal_end_block &&
            blocks_avail > 0) {
 
                for (i = dev->checkpt_next_block; i <= dev->internal_end_block;
@@ -160,7 +160,7 @@ static void yaffs2_checkpt_find_erased_block(struct yaffs_dev *dev)
 
 static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
 {
-       int i;
+       u32 i;
        struct yaffs_ext_tags tags;
 
        yaffs_trace(YAFFS_TRACE_CHECKPOINT,
@@ -210,7 +210,7 @@ static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
 
 int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing)
 {
-       int i;
+       u32 i;
 
        dev->checkpt_open_write = writing;
 
@@ -319,7 +319,7 @@ static int yaffs2_checkpt_flush_buffer(struct yaffs_dev *dev)
                                       dev->checkpt_buffer, &tags);
        dev->checkpt_page_seq++;
        dev->checkpt_cur_chunk++;
-       if (dev->checkpt_cur_chunk >= dev->param.chunks_per_block) {
+       if (dev->checkpt_cur_chunk >= (int)dev->param.chunks_per_block) {
                dev->checkpt_cur_chunk = 0;
                dev->checkpt_cur_block = -1;
        }
@@ -354,7 +354,7 @@ int yaffs2_checkpt_wr(struct yaffs_dev *dev, const void *data, int n_bytes)
                dev->checkpt_byte_count++;
 
                if (dev->checkpt_byte_offs < 0 ||
-                   dev->checkpt_byte_offs >= dev->data_bytes_per_chunk)
+                   dev->checkpt_byte_offs >= (int)dev->data_bytes_per_chunk)
                        ok = yaffs2_checkpt_flush_buffer(dev);
        }
 
@@ -378,7 +378,7 @@ int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes)
        while (i < n_bytes) {
 
                if (dev->checkpt_byte_offs < 0 ||
-                   dev->checkpt_byte_offs >= dev->data_bytes_per_chunk) {
+                   dev->checkpt_byte_offs >= (int)dev->data_bytes_per_chunk) {
 
                        if (dev->checkpt_cur_block < 0) {
                                yaffs2_checkpt_find_block(dev);
@@ -403,7 +403,7 @@ int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes)
                                                &tags);
 
                        /* Bail out if the chunk is corrupted. */
-                       if (tags.chunk_id != (dev->checkpt_page_seq + 1) ||
+                       if (tags.chunk_id != (u32)(dev->checkpt_page_seq + 1) ||
                            tags.ecc_result > YAFFS_ECC_RESULT_FIXED ||
                            tags.seq_number != YAFFS_SEQUENCE_CHECKPOINT_DATA)
                                break;
@@ -416,7 +416,7 @@ int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes)
                        dev->checkpt_cur_chunk++;
 
                        if (dev->checkpt_cur_chunk >=
-                                       dev->param.chunks_per_block)
+                                       (int)dev->param.chunks_per_block)
                                dev->checkpt_cur_block = -1;
 
                }
@@ -435,7 +435,7 @@ int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes)
 
 int yaffs_checkpt_close(struct yaffs_dev *dev)
 {
-       int i;
+       u32 i;
 
        if (dev->checkpt_open_write) {
                if (dev->checkpt_byte_offs !=
@@ -448,8 +448,8 @@ int yaffs_checkpt_close(struct yaffs_dev *dev)
                        int blk = dev->checkpt_block_list[i];
                        struct yaffs_block_info *bi = NULL;
 
-                       if (dev->internal_start_block <= blk &&
-                           blk <= dev->internal_end_block)
+                       if ((int)dev->internal_start_block <= blk &&
+                           blk <= (int)dev->internal_end_block)
                                bi = yaffs_get_block_info(dev, blk);
                        if (bi && bi->block_state == YAFFS_BLOCK_STATE_EMPTY)
                                bi->block_state = YAFFS_BLOCK_STATE_CHECKPOINT;
index 0bc67fef41f8b5a906ccf7a681fa58a2f27911da..8c291ad3c8f10d55cbcc476773ef1ce2c9feddf7 100644 (file)
@@ -37,7 +37,7 @@ void yaffs_do_endian_oh(struct yaffs_dev *dev, struct yaffs_obj_hdr *oh)
                return;
        /* Change every field */
        oh->type = swap_u32(oh->type);
-       oh->parent_obj_id = swap_s32(oh->parent_obj_id);
+       oh->parent_obj_id = swap_u32(oh->parent_obj_id);
 
        oh->yst_mode = swap_u32(oh->yst_mode);
 
index 8fd0802bdddbfc4721eb1b29effd099c472710fb..09b5a166fc9be9b31c76ccbfd345f33b4bc93cb8 100644 (file)
@@ -23,7 +23,8 @@
 static inline struct yaffs_block_info *yaffs_get_block_info(struct yaffs_dev
                                                              *dev, int blk)
 {
-       if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
+       if (blk < (int)dev->internal_start_block ||
+           blk > (int)dev->internal_end_block) {
                yaffs_trace(YAFFS_TRACE_ERROR,
                        "**>> yaffs: get_block_info block %d is not valid",
                        blk);
index 72555d53ed08a6ec7864ddb5c598768fb140eda8..e95d87022f95d3f51cea961671eef476e410ef89 100644 (file)
@@ -303,7 +303,8 @@ static int yaffs_check_chunk_erased(struct yaffs_dev *dev, int nand_chunk)
 
        result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags);
 
-       if (tags.ecc_result > YAFFS_ECC_RESULT_NO_ERROR)
+       if (result == YAFFS_FAIL ||
+           tags.ecc_result > YAFFS_ECC_RESULT_NO_ERROR)
                retval = YAFFS_FAIL;
 
        if (!yaffs_check_ff(data, dev->data_bytes_per_chunk) ||
@@ -330,7 +331,8 @@ static int yaffs_verify_chunk_written(struct yaffs_dev *dev,
        int result;
 
        result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags);
-       if (memcmp(buffer, data, dev->data_bytes_per_chunk) ||
+       if (result == YAFFS_FAIL ||
+           memcmp(buffer, data, dev->data_bytes_per_chunk) ||
            temp_tags.obj_id != tags->obj_id ||
            temp_tags.chunk_id != tags->chunk_id ||
            temp_tags.n_bytes != tags->n_bytes)
@@ -358,7 +360,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) {
@@ -375,8 +377,8 @@ static int yaffs_find_alloc_block(struct yaffs_dev *dev)
 
        for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
                dev->alloc_block_finder++;
-               if (dev->alloc_block_finder < dev->internal_start_block
-                   || dev->alloc_block_finder > dev->internal_end_block) {
+               if (dev->alloc_block_finder < (int)dev->internal_start_block
+                   || dev->alloc_block_finder > (int)dev->internal_end_block) {
                        dev->alloc_block_finder = dev->internal_start_block;
                }
 
@@ -419,7 +421,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");
 
@@ -488,7 +490,7 @@ static int yaffs_write_new_chunk(struct yaffs_dev *dev,
                                 const u8 *data,
                                 struct yaffs_ext_tags *tags, int use_reserver)
 {
-       int attempts = 0;
+       u32 attempts = 0;
        int write_ok = 0;
        int chunk;
 
@@ -569,7 +571,7 @@ static int yaffs_write_new_chunk(struct yaffs_dev *dev,
                yaffs_handle_chunk_wr_ok(dev, chunk, data, tags);
 
        } while (write_ok != YAFFS_OK &&
-                (yaffs_wr_attempts <= 0 || attempts <= yaffs_wr_attempts));
+                (yaffs_wr_attempts == 0 || attempts <= yaffs_wr_attempts));
 
        if (!write_ok)
                chunk = -1;
@@ -1019,8 +1021,8 @@ struct yaffs_tnode *yaffs_add_find_tnode_0(struct yaffs_dev *dev,
 static int yaffs_tags_match(const struct yaffs_ext_tags *tags, int obj_id,
                            int chunk_obj)
 {
-       return (tags->chunk_id == chunk_obj &&
-               tags->obj_id == obj_id &&
+       return (tags->chunk_id == (u32)chunk_obj &&
+               tags->obj_id == (u32)obj_id &&
                !tags->is_deleted) ? 1 : 0;
 
 }
@@ -1520,7 +1522,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++) {
@@ -1536,7 +1538,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev)
 {
        struct yaffs_cache *cache;
        int usage;
-       int i;
+       u32 i;
 
        if (dev->param.n_caches < 1)
                return NULL;
@@ -1580,7 +1582,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;
@@ -1600,7 +1602,7 @@ 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;
+       u32 i;
 
        if (dev->param.n_caches < 1)
                return;
@@ -1641,7 +1643,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) {
@@ -2364,7 +2366,7 @@ void yaffs_block_became_dirty(struct yaffs_dev *dev, int 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.
@@ -2380,12 +2382,12 @@ void yaffs_block_became_dirty(struct yaffs_dev *dev, int block_no)
        bi->block_state = YAFFS_BLOCK_STATE_DIRTY;
 
        /* If this is the block being garbage collected then stop gc'ing */
-       if (block_no == dev->gc_block)
+       if (block_no == (int)dev->gc_block)
                dev->gc_block = 0;
 
        /* If this block is currently the best candidate for gc
         * then drop as a candidate */
-       if (block_no == dev->gc_dirtiest) {
+       if (block_no == (int)dev->gc_dirtiest) {
                dev->gc_dirtiest = 0;
                dev->gc_pages_in_use = 0;
        }
@@ -2589,7 +2591,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);
@@ -2694,13 +2696,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;
-       unsigned selected = 0;
+       u32 i;
+       u32 iterations;
+       u32 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) {
@@ -2741,14 +2743,14 @@ static unsigned yaffs_find_gc_block(struct yaffs_dev *dev,
         */
 
        if (!selected) {
-               int pages_used;
+               u32 pages_used;
                int 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;
@@ -2934,14 +2936,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;
@@ -3075,7 +3077,7 @@ static int yaffs_wr_data_obj(struct yaffs_obj *in, int inode_chunk,
            (prev_chunk_id > 0) ? prev_tags.serial_number + 1 : 1;
        new_tags.n_bytes = n_bytes;
 
-       if (n_bytes < 1 || n_bytes > dev->data_bytes_per_chunk) {
+       if (n_bytes < 1 || n_bytes > (int)dev->data_bytes_per_chunk) {
                yaffs_trace(YAFFS_TRACE_ERROR,
                  "Writing %d bytes to chunk!!!!!!!!!",
                   n_bytes);
@@ -3235,30 +3237,30 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in)
        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;
 
        dev = in->my_dev;
-       in->lazy_loaded = 0;
        buf = yaffs_get_temp_buffer(dev);
 
        result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags);
+
+       if (result == YAFFS_FAIL)
+               return;
+
        oh = (struct yaffs_obj_hdr *)buf;
 
        yaffs_do_endian_oh(dev, oh);
 
+       in->lazy_loaded = 0;
        in->yst_mode = oh->yst_mode;
        yaffs_load_attribs(in, oh);
        yaffs_set_obj_name_from_oh(in, oh);
 
-       if (in->variant_type == YAFFS_OBJECT_TYPE_SYMLINK) {
+       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);
 }
 
@@ -3311,15 +3313,16 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force,
                /* Access the old obj header just to read the name. */
                result = yaffs_rd_chunk_tags_nand(dev, prev_chunk_id,
                                                  buffer, &old_tags);
-
-               yaffs_verify_oh(in, oh, &old_tags, 0);
-               memcpy(old_name, oh->name, sizeof(oh->name));
-
-               /*
-                * NB We only wipe the object header area because the rest of
-                * the buffer might contain xattribs.
-                */
-               memset(oh, 0xff, sizeof(*oh));
+               if (result == YAFFS_OK) {
+                       yaffs_verify_oh(in, oh, &old_tags, 0);
+                       memcpy(old_name, oh->name, sizeof(oh->name));
+
+                       /*
+                       * NB We only wipe the object header area because the rest of
+                       * the buffer might contain xattribs.
+                       */
+                       memset(oh, 0xff, sizeof(*oh));
+               }
        } else {
                memset(buffer, 0xff, dev->data_bytes_per_chunk);
        }
@@ -3471,7 +3474,7 @@ int yaffs_file_rd(struct yaffs_obj *in, u8 * buffer, loff_t offset, int n_bytes)
                 * a whole chunk or we're using inband tags then use the cache
                 * (if there is caching) else bypass the cache.
                 */
-               if (cache || n_copy != dev->data_bytes_per_chunk ||
+               if (cache || n_copy != (int)dev->data_bytes_per_chunk ||
                    dev->param.inband_tags) {
                        if (dev->param.n_caches > 0) {
 
@@ -3546,7 +3549,7 @@ int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset,
                    start >= dev->data_bytes_per_chunk) {
                        yaffs_trace(YAFFS_TRACE_ERROR,
                                "AddrToChunk of offset %lld gives chunk %d start %d",
-                               offset, chunk, start);
+                               (long  long)offset, chunk, start);
                }
                chunk++;        /* File pos to chunk in file offset */
 
@@ -3581,7 +3584,7 @@ int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset,
                             (start + n)) ? n_bytes_read : (start + n);
 
                        if (n_writeback < 0 ||
-                           n_writeback > dev->data_bytes_per_chunk)
+                           n_writeback > (int)dev->data_bytes_per_chunk)
                                BUG();
 
                } else {
@@ -3589,7 +3592,7 @@ int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset,
                        n_writeback = dev->data_bytes_per_chunk;
                }
 
-               if (n_copy != dev->data_bytes_per_chunk ||
+               if (n_copy != (int)dev->data_bytes_per_chunk ||
                    !dev->param.cache_bypass_aligned ||
                    dev->param.inband_tags) {
                        /* An incomplete start or end chunk (or maybe both
@@ -3737,9 +3740,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,
@@ -4535,7 +4538,8 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size)
                                                          obj->hdr_chunk,
                                                          buffer, NULL);
                }
-               yaffs_load_name_from_oh(obj->my_dev, name, oh->name,
+               if (result == YAFFS_OK)
+                       yaffs_load_name_from_oh(obj->my_dev, name, oh->name,
                                        buffer_size);
 
                yaffs_release_temp_buffer(obj->my_dev, buffer);
@@ -4779,7 +4783,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;
 
@@ -4802,8 +4806,8 @@ int yaffs_guts_format_dev(struct yaffs_dev *dev)
 int yaffs_guts_initialise(struct yaffs_dev *dev)
 {
        int init_failed = 0;
-       unsigned x;
-       int bits;
+       u32 x;
+       u32 bits;
 
        if(yaffs_guts_ll_init(dev) != YAFFS_OK)
                return YAFFS_FAIL;
@@ -4915,9 +4919,9 @@ 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 =
+               u32 cache_bytes =
                    dev->param.n_caches * sizeof(struct yaffs_cache);
 
                if (dev->param.n_caches > YAFFS_MAX_SHORT_OP_CACHES)
@@ -5050,7 +5054,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);
@@ -5088,7 +5092,7 @@ void yaffs_deinitialise(struct yaffs_dev *dev)
 int yaffs_count_free_chunks(struct yaffs_dev *dev)
 {
        int n_free = 0;
-       int b;
+       u32 b;
        struct yaffs_block_info *blk;
 
        blk = dev->block_info;
@@ -5116,7 +5120,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;
@@ -5193,7 +5197,7 @@ loff_t yaffs_oh_to_size(struct yaffs_dev *dev, 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;
 
index c7e201cbdc56737ee9ab412f7c92bc32233ebec6..6bcf12dcd07fe676beb97f58cd43cae47d0f467c 100644 (file)
@@ -324,7 +324,7 @@ struct yaffs_obj_hdr {
        u32 type;  /* enum yaffs_obj_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
@@ -644,7 +644,7 @@ 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
@@ -670,8 +670,8 @@ struct yaffs_dev {
        int swap_endian;        /* Stored endian needs endian swap. */
 
        /* 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;
 
@@ -681,12 +681,12 @@ struct yaffs_dev {
        int checkpt_byte_offs;
        u8 *checkpt_buffer;
        int checkpt_open_write;
-       int blocks_in_checkpt;
+       u32 blocks_in_checkpt;
        int checkpt_cur_chunk;
        int checkpt_cur_block;
        int checkpt_next_block;
        int *checkpt_block_list;
-       int checkpt_max_blocks;
+       u32 checkpt_max_blocks;
        u32 checkpt_sum;
        u32 checkpt_xor;
 
@@ -892,6 +892,8 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev);
 int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR * old_name,
                     struct yaffs_obj *new_dir, const YCHAR * new_name);
 
+int yaffs_unlink_obj(struct yaffs_obj *obj);
+
 int yaffs_unlinker(struct yaffs_obj *dir, const YCHAR * name);
 int yaffs_del_obj(struct yaffs_obj *obj);
 struct yaffs_obj *yaffs_retype_obj(struct yaffs_obj *obj,
index 478248e651a996928f9157f9cfc984afa07a64f7..eeb75be0f86089818988f5b0b9d2fb07d8c239c0 100644 (file)
@@ -28,6 +28,7 @@
 #include "yaffs_nameval.h"
 #include "yaffs_guts.h"
 #include "yportenv.h"
+#include "yaffs_endian.h"
 
 static int nval_find(struct yaffs_dev *dev,
                     const char *xb, int xb_size, const YCHAR *name,
@@ -47,7 +48,7 @@ static int nval_find(struct yaffs_dev *dev,
                        return pos;
                }
                pos += size;
-               if (pos < xb_size - sizeof(size)) {
+               if (pos < (int)(xb_size - sizeof(size))) {
                        memcpy(&size, xb + pos, sizeof(size));
                        yaffs_do_endian_s32(dev, &size);
 
@@ -69,7 +70,7 @@ static int nval_used(struct yaffs_dev *dev, const char *xb, int xb_size)
 
        while (size > 0 && (size < xb_size) && (pos + size < xb_size)) {
                pos += size;
-               if (pos < xb_size - sizeof(size)) {
+               if (pos < (int)(xb_size - sizeof(size))) {
                        memcpy(&size, xb + pos, sizeof(size));
                        yaffs_do_endian_s32(dev, &size);
                } else
@@ -192,7 +193,7 @@ int nval_list(struct yaffs_dev *dev, const char *xb, int xb_size, char *buf, int
        memcpy(&size, xb + pos, sizeof(size));
        yaffs_do_endian_s32(dev, &size);
 
-       while (size > sizeof(size) &&
+       while (size > (int)(sizeof(size)) &&
                size <= xb_size &&
                (pos + size) < xb_size &&
                !filled) {
@@ -213,7 +214,7 @@ int nval_list(struct yaffs_dev *dev, const char *xb, int xb_size, char *buf, int
                        filled = 1;
                }
                pos += size;
-               if (pos < xb_size - sizeof(size)) {
+               if (pos < (int)(xb_size - sizeof(size))) {
                        memcpy(&size, xb + pos, sizeof(size));
                        yaffs_do_endian_s32(dev, &size);
                }
index 025096316494cf1f708d869132d5e84c74ea4b58..1e7776ba1341b039d9f3e918f49fabbf5accc7dc 100644 (file)
@@ -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;
@@ -191,10 +191,7 @@ int yaffs_summary_read(struct yaffs_dev *dev,
        struct yaffs_summary_header hdr;
        struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk);
        int sum_bytes_per_chunk = dev->data_bytes_per_chunk - sizeof(hdr);
-       int sum_tags_bytes;
 
-       sum_tags_bytes = sizeof(struct yaffs_summary_tags) *
-                               dev->chunks_per_summary;
        buffer = yaffs_get_temp_buffer(dev);
        n_bytes = sizeof(struct yaffs_summary_tags) * dev->chunks_per_summary;
        chunk_in_block = dev->chunks_per_summary;
@@ -296,7 +293,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;
index c2e2369bb24731e58fce8d1ccfa1300232854932..4a120d86825a4405969d73b251655bf527581c8a 100644 (file)
@@ -101,6 +101,9 @@ static int yaffs_tags_marshall_read(struct yaffs_dev *dev,
                BUG();
 
 
+       if (retval == YAFFS_FAIL)
+               return YAFFS_FAIL;
+
        if (dev->param.inband_tags) {
                if (tags) {
                        struct yaffs_packed_tags2_tags_only *pt2tp;
@@ -122,7 +125,7 @@ static int yaffs_tags_marshall_read(struct yaffs_dev *dev,
                dev->n_ecc_unfixed++;
        }
 
-       if (tags && ecc_result == -YAFFS_ECC_RESULT_FIXED) {
+       if (tags && ecc_result == YAFFS_ECC_RESULT_FIXED) {
                if (tags->ecc_result <= YAFFS_ECC_RESULT_NO_ERROR)
                        tags->ecc_result = YAFFS_ECC_RESULT_FIXED;
                dev->n_ecc_fixed++;
index 4a2f5c3a0abc626ae7a78b120288a76e72b4f625..7a341a283079f0d98a84f566f4d86fac3193a8fd 100644 (file)
@@ -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,8 +110,8 @@ void yaffs_verify_collected_blk(struct yaffs_dev *dev,
 
 void yaffs_verify_blocks(struct yaffs_dev *dev)
 {
-       int i;
-       int state_count[YAFFS_NUMBER_OF_BLOCK_STATES];
+       u32 i;
+       u32 state_count[YAFFS_NUMBER_OF_BLOCK_STATES];
        int illegal_states = 0;
 
        if (yaffs_skip_verification(dev))
@@ -149,7 +149,7 @@ void yaffs_verify_blocks(struct yaffs_dev *dev)
                        dev->blocks_in_checkpt,
                        state_count[YAFFS_BLOCK_STATE_CHECKPOINT]);
 
-       if (dev->n_erased_blocks != state_count[YAFFS_BLOCK_STATE_EMPTY])
+       if (dev->n_erased_blocks != (int)state_count[YAFFS_BLOCK_STATE_EMPTY])
                yaffs_trace(YAFFS_TRACE_VERIFY,
                        "Erased block count wrong dev %d count %d",
                        dev->n_erased_blocks,
@@ -201,7 +201,7 @@ void yaffs_verify_oh(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh,
                        tags->obj_id, oh->parent_obj_id);
 
        if (parent_check && obj->parent &&
-           oh->parent_obj_id != obj->parent->obj_id &&
+           oh->parent_obj_id !=  obj->parent->obj_id &&
            (oh->parent_obj_id != YAFFS_OBJECTID_UNLINKED ||
             obj->parent->obj_id != YAFFS_OBJECTID_DELETED))
                yaffs_trace(YAFFS_TRACE_VERIFY,
@@ -224,12 +224,11 @@ void yaffs_verify_file(struct yaffs_obj *obj)
 {
        u32 x;
        int required_depth;
-       int actual_depth;
        int last_chunk;
        u32 offset_in_chunk;
        u32 the_chunk;
 
-       u32 i;
+       int i;
        struct yaffs_dev *dev;
        struct yaffs_ext_tags tags;
        struct yaffs_tnode *tn;
@@ -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.
@@ -276,7 +273,7 @@ void yaffs_verify_file(struct yaffs_obj *obj)
                if (the_chunk > 0) {
                        yaffs_rd_chunk_tags_nand(dev, the_chunk, NULL,
                                                 &tags);
-                       if (tags.obj_id != obj_id || tags.chunk_id != i)
+                       if (tags.obj_id != obj_id || tags.chunk_id != (u32)i)
                                yaffs_trace(YAFFS_TRACE_VERIFY,
                                        "Object %d chunk_id %d NAND mismatch chunk %d tags (%d:%d)",
                                        obj_id, i, the_chunk,
index e98d04d434a3b9c68bcc5c2c1db7e21f5d024153..0cdc8c80c108017ef351b8b51d29fd922b6d3480 100644 (file)
 int yaffs1_scan(struct yaffs_dev *dev)
 {
        struct yaffs_ext_tags tags;
-       int blk;
+       u32 blk;
        int result;
        int chunk;
-       int c;
+       u32 c;
        int deleted;
        enum yaffs_block_state state;
        LIST_HEAD(hard_list);
@@ -98,6 +98,8 @@ int yaffs1_scan(struct yaffs_dev *dev)
                        result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL,
                                                          &tags);
 
+                       if (result != YAFFS_OK)
+                               continue;
                        /* Let's have a good look at this chunk... */
 
                        if (tags.ecc_result == YAFFS_ECC_RESULT_UNFIXED ||
index 6d4681726a60b3ae63adc3456661a8652790194a..47fa8eba2d5c049c86700a930a6b50323b034416 100644 (file)
@@ -42,7 +42,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)
        b = dev->block_info;
        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) <
+                   (u32)(b->pages_in_use - b->soft_del_pages) <
                    dev->param.chunks_per_block &&
                    b->seq_number < seq) {
                        seq = b->seq_number;
@@ -345,7 +345,7 @@ static int yaffs2_wr_checkpt_dev(struct yaffs_dev *dev)
        u32 n_bytes;
        u32 n_blocks = dev->internal_end_block - dev->internal_start_block + 1;
        int ok;
-       int i;
+       u32 i;
        union yaffs_block_info_union bu;
 
        /* Write device runtime values */
@@ -359,7 +359,8 @@ static int yaffs2_wr_checkpt_dev(struct yaffs_dev *dev)
        /* Write block info. */
        if (!dev->swap_endian) {
                n_bytes = n_blocks * sizeof(struct yaffs_block_info);
-               ok = (yaffs2_checkpt_wr(dev, dev->block_info, n_bytes) == n_bytes);
+               ok = (yaffs2_checkpt_wr(dev, dev->block_info, n_bytes) ==
+                       (int)n_bytes);
        } else {
                /*
                 * Need to swap the endianisms. We can't do this in place
@@ -382,7 +383,8 @@ static int yaffs2_wr_checkpt_dev(struct yaffs_dev *dev)
         * no endian conversion is needed.
         */
        n_bytes = n_blocks * dev->chunk_bit_stride;
-       ok = (yaffs2_checkpt_wr(dev, dev->chunk_bits, n_bytes) == n_bytes);
+       ok = (yaffs2_checkpt_wr(dev, dev->chunk_bits, n_bytes) ==
+               (int)n_bytes);
 
        return ok ? 1 : 0;
 }
@@ -407,7 +409,8 @@ static int yaffs2_rd_checkpt_dev(struct yaffs_dev *dev)
 
        n_bytes = n_blocks * sizeof(struct yaffs_block_info);
 
-       ok = (yaffs2_checkpt_rd(dev, dev->block_info, n_bytes) == n_bytes);
+       ok = (yaffs2_checkpt_rd(dev, dev->block_info, n_bytes) ==
+               (int)n_bytes);
 
        if (!ok)
                return 0;
@@ -424,7 +427,8 @@ static int yaffs2_rd_checkpt_dev(struct yaffs_dev *dev)
 
        n_bytes = n_blocks * dev->chunk_bit_stride;
 
-       ok = (yaffs2_checkpt_rd(dev, dev->chunk_bits, n_bytes) == n_bytes);
+       ok = (yaffs2_checkpt_rd(dev, dev->chunk_bits, n_bytes) ==
+               (int)n_bytes);
 
 
        return ok ? 1 : 0;
@@ -604,7 +608,7 @@ static int yaffs2_checkpt_tnode_worker(struct yaffs_obj *in,
                 */
                tn = yaffs2_do_endian_tnode_copy(dev, tn);
                ok = (yaffs2_checkpt_wr(dev, tn, dev->tnode_size) ==
-                       dev->tnode_size);
+                       (int)dev->tnode_size);
        }
        return ok;
 }
@@ -649,7 +653,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);
                        yaffs2_do_endian_tnode(dev, tn);
                }
                else
@@ -768,7 +772,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 =
@@ -1050,7 +1054,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,
@@ -1136,6 +1140,9 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev,
                dev->summary_used++;
        }
 
+       if (result == YAFFS_FAIL)
+               yaffs_trace(YAFFS_TRACE_SCAN,
+                               "Could not get tags for chunk %d\n", chunk);
        /* Let's have a good look at this chunk... */
 
        if (!tags.chunk_used) {
@@ -1334,7 +1341,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev,
                                        yaffs_oh_to_size(dev, oh, 0) :
                                        tags.extra_file_size;
                                u32 parent_obj_id = (oh) ?
-                                       oh->parent_obj_id :
+                                       (u32)oh->parent_obj_id :
                                        tags.extra_parent_id;
 
                                is_shrink = (oh) ?
@@ -1517,7 +1524,7 @@ 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;