Yaffs Clean ups block-refreshing
authorCharles Manning <cdhmanning@gmail.com>
Tue, 26 Aug 2014 01:19:58 +0000 (13:19 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Tue, 26 Aug 2014 01:19:58 +0000 (13:19 +1200)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/test-framework/tests/nor_stress.c
direct/test-framework/tests/yaffs_fsx.c
direct/yaffsfs.c
yaffs_guts.c
yaffs_nand.h
yaffs_summary.c
yaffs_tagsmarshall.c

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..40a43ab8accd7ec0cf514befa08b3c84cee0f8e8 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
  *
@@ -123,7 +123,7 @@ unsigned long       simulatedopcount = 0;   /* -b flag */
 int    closeprob = 0;                  /* -c flag */
 int    debug = 0;                      /* -d flag */
 unsigned long  debugstart = 0;         /* -D flag */
-unsigned long  maxfilelen = 256 * 1024;        /* -l flag */
+long int maxfilelen = 256 * 1024;      /* -l flag */
 int    sizechecks = 1;                 /* -n flag disables them */
 int    maxoplen = 64 * 1024;           /* -o flag */
 int    quiet = 0;                      /* -q 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);
@@ -449,10 +449,10 @@ check_trunc_hack(void)
 
 
 void
-doread(unsigned offset, unsigned size)
+doread(unsigned offset, int size)
 {
        off_t ret;
-       unsigned iret;
+       int iret;
 
        offset -= offset % readbdy;
        if (size == 0) {
@@ -506,7 +506,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++;
@@ -515,10 +515,10 @@ gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
 
 
 void
-dowrite(unsigned offset, unsigned size)
+dowrite(unsigned offset, int size)
 {
        off_t ret;
-       unsigned iret;
+       int iret;
 
        offset -= offset % writebdy;
        if (size == 0) {
@@ -590,7 +590,7 @@ dotruncate(unsigned size)
 
        if (testcalls <= simulatedopcount)
                return;
-       
+
        if ((progressinterval && testcalls % progressinterval == 0) ||
            (debug && (monitorstart == -1 || monitorend == -1 ||
                       size <= monitorend)))
@@ -631,7 +631,7 @@ writefileimage()
 
 void
 docloseopen(void)
-{ 
+{
        if (testcalls <= simulatedopcount)
                return;
 
@@ -652,10 +652,10 @@ docloseopen(void)
 void
 yaffs_fsx_do_op(void)
 {
-       unsigned long   offset;
-       unsigned long   size = maxoplen;
-       unsigned long   rv = random();
-       unsigned long   op = rv % (3 + !lite + mapped_writes);
+       long int        offset;
+       long int        size = maxoplen;
+       long int        rv = random();
+       long int        op = rv % (3 + !lite + mapped_writes);
 
        /* turn off the map read if necessary */
 
@@ -812,7 +812,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);
@@ -882,11 +882,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 +897,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 +913,6 @@ yaffs_fsx_main(const char *mount_pt, int numops)
        while (numops == -1 || numops--)
                yaffs_fsx_do_op();
        yaffs_fsx_complete();
-       
+
        return 0;
 }
index 69cf0a48ad9e424d7fc53890683cc1af61682e87..6d97cbf4c3f85c5ece16b5e6b9ea45aa5ab8aea4 100644 (file)
@@ -1855,7 +1855,6 @@ static int yaffsfs_DoUtime(struct yaffs_obj *obj,
                           const struct yaffs_utimbuf *buf)
 {
        int retVal = -1;
-       struct yaffs_utimbuf local;
 
        obj = yaffs_get_equivalent_obj(obj);
 
@@ -1865,20 +1864,24 @@ static int yaffsfs_DoUtime(struct yaffs_obj *obj,
        }
 
 #if !CONFIG_YAFFS_WINCE
-       if (!buf) {
-               local.actime = Y_CURRENT_TIME;
-               local.modtime = local.actime;
-               buf = &local;
-       }
+       {
+               struct yaffs_utimbuf local;
 
-       if (obj) {
-               int result;
+               if (!buf) {
+                       local.actime = Y_CURRENT_TIME;
+                       local.modtime = local.actime;
+                       buf = &local;
+               }
 
-               obj->yst_atime = buf->actime;
-               obj->yst_mtime = buf->modtime;
-               obj->dirty = 1;
-               result = yaffs_flush_file(obj, 0, 0, 0);
-               retVal = result == YAFFS_OK ? 0 : -1;
+               if (obj) {
+                       int result;
+
+                       obj->yst_atime = buf->actime;
+                       obj->yst_mtime = buf->modtime;
+                       obj->dirty = 1;
+                       result = yaffs_flush_file(obj, 0, 0, 0);
+                       retVal = result == YAFFS_OK ? 0 : -1;
+               }
        }
 #endif
 
index 35440d28aed074bcbc26e7ae61e18dd16cd4be7c..aee80de4e55c6d9a815e01e127dd8a3eee88608f 100644 (file)
@@ -691,7 +691,7 @@ static void yaffs_load_oh_from_name(struct yaffs_dev *dev, YCHAR *oh_name,
                        char *ascii_oh_name = (char *)oh_name;
                        int n = YAFFS_MAX_NAME_LENGTH - 1;
                        while (n > 0 && *name) {
-                               *ascii_oh_name = *name;
+                               *ascii_oh_name = (char)*name;
                                name++;
                                ascii_oh_name++;
                                n--;
@@ -871,7 +871,7 @@ u32 yaffs_get_group_base(struct yaffs_dev *dev, struct yaffs_tnode *tn,
  * in the tree. 0 means only the level 0 tnode is in the tree.
  */
 
-/* FindLevel0Tnode finds the level 0 tnode, if one exists. */
+/* yaffs_find_tnode_0 finds the level 0 tnode, if one exists. */
 struct yaffs_tnode *yaffs_find_tnode_0(struct yaffs_dev *dev,
                                       struct yaffs_file_var *file_struct,
                                       u32 chunk_id)
@@ -4823,7 +4823,7 @@ int yaffs_guts_initialise(struct yaffs_dev *dev)
        if (bits <= dev->tnode_width)
                dev->chunk_grp_bits = 0;
        else
-               dev->chunk_grp_bits = bits - dev->tnode_width;
+               dev->chunk_grp_bits = (u16)(bits - dev->tnode_width);
 
        dev->tnode_size = (dev->tnode_width * YAFFS_NTNODES_LEVEL0) / 8;
        if (dev->tnode_size < sizeof(struct yaffs_tnode))
index 804e97ad66d0ca50385b730af435ea1d944d90eb..07424cadf3db956c832c54097fc63ef621e6cb63 100644 (file)
@@ -29,7 +29,7 @@ int yaffs_mark_bad(struct yaffs_dev *dev, int block_no);
 int yaffs_query_init_block_state(struct yaffs_dev *dev,
                                 int block_no,
                                 enum yaffs_block_state *state,
-                                unsigned *seq_number);
+                                u32 *seq_number);
 
 int yaffs_erase_block(struct yaffs_dev *dev, int flash_block);
 
index 3c9e72321ea4ce6c4d03a545c34a0d6948cc8160..e9e1b5d85776939c20e37e272343c9eb44f1bf1a 100644 (file)
@@ -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;
index 44a83b12ca4d07cfa84fbb86fc80961ff738bf5a..a5989fa952355958bffa92c8071fc5d6ff2dad0c 100644 (file)
@@ -118,7 +118,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++;