From bdb04f601934f804c982cbd1ae6add208c96732b Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Tue, 26 Aug 2014 13:19:58 +1200 Subject: [PATCH] Yaffs Clean ups Signed-off-by: Charles Manning --- direct/test-framework/tests/nor_stress.c | 1 + direct/test-framework/tests/yaffs_fsx.c | 48 ++++++++++++------------ direct/yaffsfs.c | 29 +++++++------- yaffs_guts.c | 6 +-- yaffs_nand.h | 2 +- yaffs_summary.c | 3 -- yaffs_tagsmarshall.c | 2 +- 7 files changed, 46 insertions(+), 45 deletions(-) diff --git a/direct/test-framework/tests/nor_stress.c b/direct/test-framework/tests/nor_stress.c index adf1b29..93a9a8e 100644 --- a/direct/test-framework/tests/nor_stress.c +++ b/direct/test-framework/tests/nor_stress.c @@ -19,6 +19,7 @@ #include "yaffs_fsx.h" #include +#include extern int fuzz_test; diff --git a/direct/test-framework/tests/yaffs_fsx.c b/direct/test-framework/tests/yaffs_fsx.c index aa234cd..40a43ab 100644 --- a/direct/test-framework/tests/yaffs_fsx.c +++ b/direct/test-framework/tests/yaffs_fsx.c @@ -24,12 +24,12 @@ * 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; } diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 69cf0a4..6d97cbf 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -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 diff --git a/yaffs_guts.c b/yaffs_guts.c index 35440d2..aee80de 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -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)) diff --git a/yaffs_nand.h b/yaffs_nand.h index 804e97a..07424ca 100644 --- a/yaffs_nand.h +++ b/yaffs_nand.h @@ -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); diff --git a/yaffs_summary.c b/yaffs_summary.c index 3c9e723..e9e1b5d 100644 --- a/yaffs_summary.c +++ b/yaffs_summary.c @@ -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; diff --git a/yaffs_tagsmarshall.c b/yaffs_tagsmarshall.c index 44a83b1..a5989fa 100644 --- a/yaffs_tagsmarshall.c +++ b/yaffs_tagsmarshall.c @@ -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++; -- 2.30.2