From: Charles Manning Date: Wed, 8 Sep 2010 23:35:09 +0000 (+1200) Subject: yaffs Compilation clean ups X-Git-Tag: pre-name-change~15 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=9b9fd2ac90990fed4990feec36ab1ec55fc78926 yaffs Compilation clean ups Tighten compilation flags and clean up. More to follow... Signed-off-by: Charles Manning --- diff --git a/direct/basic-test/Makefile b/direct/basic-test/Makefile index 5462d6a..2b52cca 100644 --- a/direct/basic-test/Makefile +++ b/direct/basic-test/Makefile @@ -20,13 +20,15 @@ CFLAGS = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 CFLAGS += -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES -DNO_Y_INLINE -CFLAGS += -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing +CFLAGS += -Wall -g $(EXTRA_COMPILE_FLAGS) -Werror=strict-aliasing #CFLAGS += -fno-strict-aliasing CFLAGS += -O0 #CFLAGS += -DVALGRIND_TEST -#CFLAGS+= -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline +CFLAGS+= -Wshadow -Werror=pointer-arith -Werror=write-strings +CFLAGS+= -Werror=strict-prototypes -Werror=missing-parameter-type +CFLAGS+= -Werror=redundant-decls -Werror=nested-externs -Winline +CFLAGS+= -Werror=undef COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \ yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \ diff --git a/direct/basic-test/dtest.c b/direct/basic-test/dtest.c index 3ac5604..c56e5b2 100644 --- a/direct/basic-test/dtest.c +++ b/direct/basic-test/dtest.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "yaffsfs.h" @@ -28,9 +29,7 @@ extern int yaffs_traceMask; void dumpDir(const char *dname); -char xx[600]; - -void copy_in_a_file(char *yaffsName,char *inName) +void copy_in_a_file(const char *yaffsName,const char *inName) { int inh,outh; unsigned char buffer[100]; @@ -52,7 +51,7 @@ void copy_in_a_file(char *yaffsName,char *inName) close(inh); } -void make_a_file(char *yaffsName,char bval,int sizeOfFile) +void make_a_file(const char *yaffsName,char bval,int sizeOfFile) { int outh; int i; @@ -401,7 +400,8 @@ void fill_disk(const char *path,int nfiles) int n; int result; int f; - + + static char xx[600]; char str[50]; for(n = 0; n < nfiles; n++) @@ -481,7 +481,7 @@ void fill_files(const char *path,int flags, int maxIterations,int siz) } } -void leave_unlinked_file(char *path,int maxIterations,int siz) +void leave_unlinked_file(const char *path,int maxIterations,int siz) { int i; char str[50]; @@ -1498,7 +1498,7 @@ void long_name_test(const char *mountpt) char name[300]; int result = 0; - int d,f; + int f; // Make a 256 byte name memset(name,0,sizeof(name)); @@ -1602,7 +1602,6 @@ void lookup_test(const char *mountpt) void link_test0(const char *mountpt) { - int i; char namea[300]; char nameb[300]; int result = 0; @@ -2176,7 +2175,7 @@ void small_overwrite_test(const char *mountpt,int nmounts) void seek_overwrite_test(const char *mountpt,int nmounts) { - + static char xx[5000]; char a[30]; int i; @@ -2556,7 +2555,6 @@ void basic_xattr_test(const char *mountpt) int h; int result; int val1; - int valread; yaffs_StartUp(); @@ -2607,7 +2605,6 @@ void big_xattr_test(const char *mountpt) int h; int result; char val[1000]; - char valread[1000]; yaffs_StartUp(); diff --git a/direct/basic-test/yaffs_ramdisk.h b/direct/basic-test/yaffs_ramdisk.h index 57af69a..cc62fd7 100644 --- a/direct/basic-test/yaffs_ramdisk.h +++ b/direct/basic-test/yaffs_ramdisk.h @@ -25,7 +25,6 @@ int yramdisk_EraseBlockInNAND(yaffs_Device *dev, int blockNumber); int yramdisk_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_ExtendedTags *tags); int yramdisk_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags); -int yramdisk_EraseBlockInNAND(yaffs_Device *dev, int blockNumber); int yramdisk_InitialiseNAND(yaffs_Device *dev); int yramdisk_MarkNANDBlockBad(yaffs_Device *dev,int blockNumber); int yramdisk_QueryNANDBlock(yaffs_Device *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber); diff --git a/direct/basic-test/yaffscfg2k.c b/direct/basic-test/yaffscfg2k.c index b4a4590..bfd502e 100644 --- a/direct/basic-test/yaffscfg2k.c +++ b/direct/basic-test/yaffscfg2k.c @@ -152,6 +152,8 @@ int yaffs_StartUp(void) m18_1Dev.param.initialiseNAND = ynorif1_InitialiseNAND; m18_1Dev.param.deinitialiseNAND = ynorif1_DeinitialiseNAND; +// m18_1Dev.param.disableSoftDelete = 1; + yaffs_AddDevice(&m18_1Dev); // /yaffs2 yaffs2 file emulation diff --git a/direct/basic-test/yramsim.h b/direct/basic-test/yramsim.h index d842848..81a7d87 100644 --- a/direct/basic-test/yramsim.h +++ b/direct/basic-test/yramsim.h @@ -1,4 +1,20 @@ -// NAND RAM Simulator for testing YAFFS +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Charles Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 as + * published by the Free Software Foundation. + * + * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. + */ + +/* NAND RAM Simulator for testing YAFFS */ + #ifndef __YAFFS_RAM_SIM_H__ #define __YAFFS_RAM_SIM_H__ @@ -7,8 +23,10 @@ #define N_RAM_SIM_DEVS 2 -struct yaffs_DeviceStruct *yramsim_CreateSim(const YCHAR *name, +struct yaffs_DeviceStruct *yramsim_CreateRamSim(const YCHAR *name, __u32 devId, __u32 nBlocks, __u32 startBlock, __u32 endBlock); #endif + + diff --git a/direct/yaffs_flashif.h b/direct/yaffs_flashif.h index e8c2261..eec2842 100644 --- a/direct/yaffs_flashif.h +++ b/direct/yaffs_flashif.h @@ -23,7 +23,6 @@ int yflash_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, int yflash_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_ExtendedTags *tags); int yflash_ReadChunkFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_Spare *spare); int yflash_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags); -int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber); int yflash_InitialiseNAND(yaffs_Device *dev); int yflash_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo); int yflash_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, __u32 *sequenceNumber); diff --git a/direct/yaffs_nandif.c b/direct/yaffs_nandif.c index e5358a1..26d4f69 100644 --- a/direct/yaffs_nandif.c +++ b/direct/yaffs_nandif.c @@ -166,7 +166,6 @@ int ynandif_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockId, yaffs_Bl { unsigned chunkNo; yaffs_ExtendedTags tags; - ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driverContext); *sequenceNumber = 0; diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 9ac08ab..db51171 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -62,21 +62,23 @@ typedef struct{ static yaffsfs_Inode yaffsfs_inode[YAFFSFS_N_HANDLES]; static yaffsfs_Handle yaffsfs_handle[YAFFSFS_N_HANDLES]; +static int yaffsfs_handlesInitialised; /* * yaffsfs_InitHandle * Inilitalise handle management on start-up. */ -static int yaffsfs_InitHandles(void) +static void yaffsfs_InitHandles(void) { int i; + if(yaffsfs_handlesInitialised) + return; + memset(yaffsfs_inode,0,sizeof(yaffsfs_inode)); memset(yaffsfs_handle,0,sizeof(yaffsfs_handle)); for(i = 0; i < YAFFSFS_N_HANDLES; i++) yaffsfs_handle[i].inodeId = -1; - - return 0; } yaffsfs_Handle *yaffsfs_GetHandlePointer(int h) @@ -246,7 +248,7 @@ int yaffsfs_Match(YCHAR a, YCHAR b) int yaffsfs_IsPathDivider(YCHAR ch) { - YCHAR *str = YAFFS_PATH_DIVIDERS; + const YCHAR *str = YAFFS_PATH_DIVIDERS; while(*str){ if(*str == ch) @@ -1681,6 +1683,9 @@ int yaffs_mount2(const YCHAR *path,int readOnly) T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: Mounting %s" TENDSTR),path)); yaffsfs_Lock(); + + yaffsfs_InitHandles(); + dev = yaffsfs_FindDevice(path,&dummy); if(dev){ if(!dev->isMounted){ diff --git a/direct/yaffsfs.h b/direct/yaffsfs.h index 4b2ebe9..7c36dab 100644 --- a/direct/yaffsfs.h +++ b/direct/yaffsfs.h @@ -167,6 +167,7 @@ int yaffs_StartUp(void); /* Function only for debugging */ void * yaffs_getdev(const YCHAR *path); +int yaffs_DumpDevStruct(const YCHAR *path); #endif diff --git a/yaffs_guts.c b/yaffs_guts.c index 6ea5698..5db3da6 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -72,9 +72,6 @@ static void yaffs_RemoveObjectFromDirectory(yaffs_Object *obj); static int yaffs_CheckStructures(void); static int yaffs_DoGenericObjectDeletion(yaffs_Object *in); -static yaffs_BlockInfo *yaffs_GetBlockInfo(yaffs_Device *dev, int blockNo); - - static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev, int chunkInNAND); @@ -3011,7 +3008,7 @@ int yaffs_UpdateObjectHeader(yaffs_Object *in, const YCHAR *name, int force, int newChunkId; yaffs_ExtendedTags newTags; yaffs_ExtendedTags oldTags; - YCHAR *alias = NULL; + const YCHAR *alias = NULL; __u8 *buffer = NULL; YCHAR oldName[YAFFS_MAX_NAME_LENGTH + 1]; @@ -4970,7 +4967,7 @@ static int yaffs_DoXFetch(yaffs_Object *obj, const YCHAR *name, void *value, int int x_offs = sizeof(yaffs_ObjectHeader); int x_size = dev->nDataBytesPerChunk - sizeof(yaffs_ObjectHeader); - __u8 * x_buffer; + char * x_buffer; int retval = 0; @@ -4987,11 +4984,11 @@ static int yaffs_DoXFetch(yaffs_Object *obj, const YCHAR *name, void *value, int return 0; } - buffer = yaffs_GetTempBuffer(dev, __LINE__); + buffer = (char *) yaffs_GetTempBuffer(dev, __LINE__); if(!buffer) return -ENOMEM; - result = yaffs_ReadChunkWithTagsFromNAND(dev,obj->hdrChunk, buffer, &tags); + result = yaffs_ReadChunkWithTagsFromNAND(dev,obj->hdrChunk, (__u8 *)buffer, &tags); if(result != YAFFS_OK) retval = -ENOENT; @@ -5008,7 +5005,7 @@ static int yaffs_DoXFetch(yaffs_Object *obj, const YCHAR *name, void *value, int else retval = nval_list(x_buffer, x_size, value,size); } - yaffs_ReleaseTempBuffer(dev,buffer,__LINE__); + yaffs_ReleaseTempBuffer(dev,(__u8 *)buffer,__LINE__); return retval; } diff --git a/yaffs_guts.h b/yaffs_guts.h index dea450f..a2244d9 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -927,7 +927,6 @@ int yaffs_DumpObject(yaffs_Object *obj); void yaffs_GutsTest(yaffs_Device *dev); /* A few useful functions to be used within the core files*/ -void yaffs_InitialiseTags(yaffs_ExtendedTags *tags); void yaffs_DeleteChunk(yaffs_Device *dev, int chunkId, int markNAND, int lyn); int yaffs_CheckFF(__u8 *buffer, int nBytes); void yaffs_HandleChunkError(yaffs_Device *dev, yaffs_BlockInfo *bi); @@ -958,9 +957,7 @@ yaffs_Tnode *yaffs_AddOrFindLevel0Tnode(yaffs_Device *dev, yaffs_FileStructure *fStruct, __u32 chunkId, yaffs_Tnode *passedTn); -void yaffs_VerifyObjects(yaffs_Device *dev); -void yaffs_VerifyBlocks(yaffs_Device *dev); -void yaffs_VerifyFreeChunks(yaffs_Device *dev); + int yaffs_DoWriteDataToFile(yaffs_Object *in, const __u8 *buffer, loff_t offset, int nBytes, int writeThrough); void yaffs_ResizeDown( yaffs_Object *obj, loff_t newSize); diff --git a/yaffs_yaffs2.c b/yaffs_yaffs2.c index b2fd8e4..e13dd41 100644 --- a/yaffs_yaffs2.c +++ b/yaffs_yaffs2.c @@ -20,6 +20,7 @@ #include "yaffs_qsort.h" #include "yaffs_nand.h" #include "yaffs_getblockinfo.h" +#include "yaffs_verify.h" /* * Checkpoints are really no benefit on very small partitions.