yaffs Compilation clean ups
authorCharles Manning <cdhmanning@gmail.com>
Wed, 8 Sep 2010 23:35:09 +0000 (11:35 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Wed, 8 Sep 2010 23:35:09 +0000 (11:35 +1200)
Tighten compilation flags and clean up. More to follow...

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
12 files changed:
direct/basic-test/Makefile
direct/basic-test/dtest.c
direct/basic-test/yaffs_ramdisk.h
direct/basic-test/yaffscfg2k.c
direct/basic-test/yramsim.h
direct/yaffs_flashif.h
direct/yaffs_nandif.c
direct/yaffsfs.c
direct/yaffsfs.h
yaffs_guts.c
yaffs_guts.h
yaffs_yaffs2.c

index 5462d6a51e64114ce7c7dbba51e37a5c6c6b6bea..2b52ccad5051dd59e6e3ba9548e55968e21ee459 100644 (file)
 
 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 =      -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 +=    -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 \
 
 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 \
index 3ac5604284dbd3c3a577aabc19c48d47f9685861..c56e5b2a76063c5e7cd88062ed90956ad6a54685 100644 (file)
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <time.h>
 
 #include "yaffsfs.h"
 
 
 #include "yaffsfs.h"
 
@@ -28,9 +29,7 @@ extern int yaffs_traceMask;
 
 void dumpDir(const char *dname);
 
 
 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];
 {
        int inh,outh;
        unsigned char buffer[100];
@@ -52,7 +51,7 @@ void copy_in_a_file(char *yaffsName,char *inName)
        close(inh);
 }
 
        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;
 {
        int outh;
        int i;
@@ -401,7 +400,8 @@ void fill_disk(const char *path,int nfiles)
        int n;
        int result;
        int f;
        int n;
        int result;
        int f;
-       
+
+        static char xx[600];   
        char str[50];
        
        for(n = 0; n < nfiles; n++)
        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];
 {
        int i;
        char str[50];
@@ -1498,7 +1498,7 @@ void long_name_test(const char *mountpt)
        char name[300];
        int result = 0;
        
        char name[300];
        int result = 0;
        
-       int d,f;
+       int f;
        
        // Make a 256 byte name
        memset(name,0,sizeof(name));
        
        // 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)
 {
 
 void link_test0(const char *mountpt)
 {
-       int i;
        char namea[300];
        char nameb[300];
        int result = 0;
        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)
 {
 
 void seek_overwrite_test(const char *mountpt,int nmounts)
 {
-
+        static char xx[5000];
        char a[30];
        
        int i;
        char a[30];
        
        int i;
@@ -2556,7 +2555,6 @@ void basic_xattr_test(const char *mountpt)
        int h;
        int result;
        int val1;
        int h;
        int result;
        int val1;
-       int valread;
 
        yaffs_StartUp();
 
 
        yaffs_StartUp();
 
@@ -2607,7 +2605,6 @@ void big_xattr_test(const char *mountpt)
        int h;
        int result;
        char val[1000];
        int h;
        int result;
        char val[1000];
-       char valread[1000];
 
        yaffs_StartUp();
 
 
        yaffs_StartUp();
 
index 57af69a91682c97505dbd11aae7789bfbf163a5c..cc62fd718c324f8ffe83f222860a9d99ab99d1e4 100644 (file)
@@ -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_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);
 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);
index b4a45902e821a2a656b916445d1d205e5e2d483f..bfd502eb796155ef24f4e721588ad6a30df2b411 100644 (file)
@@ -152,6 +152,8 @@ int yaffs_StartUp(void)
        m18_1Dev.param.initialiseNAND = ynorif1_InitialiseNAND;
        m18_1Dev.param.deinitialiseNAND = ynorif1_DeinitialiseNAND;
 
        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
        yaffs_AddDevice(&m18_1Dev);
 
        // /yaffs2  yaffs2 file emulation
index d842848f696111683c6cd767b6cd12f53bc1dec8..81a7d87b1f763e64209c8599e25ca89f2d9188ac 100644 (file)
@@ -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 <charles@aleph1.co.uk>
+ *
+ * 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__
 
 #ifndef __YAFFS_RAM_SIM_H__
 #define __YAFFS_RAM_SIM_H__
 
@@ -7,8 +23,10 @@
 
 #define N_RAM_SIM_DEVS  2
 
 
 #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
                                                __u32 devId, __u32 nBlocks,
                                                __u32 startBlock, __u32 endBlock);
 
 #endif
+
+
index e8c2261bc0ef985089b49b07892dcfa45355a433..eec284266fac318aef371b6b8c37256a05c92524 100644 (file)
@@ -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_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);
 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);
index e5358a1bb983be3e8d997bae883f8f114a35bbc1..26d4f69a0b704978cce1494b695289e811416a2d 100644 (file)
@@ -166,7 +166,6 @@ int ynandif_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockId, yaffs_Bl
 {
        unsigned chunkNo;
        yaffs_ExtendedTags tags;
 {
        unsigned chunkNo;
        yaffs_ExtendedTags tags;
-       ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driverContext);
 
        *sequenceNumber = 0;
        
 
        *sequenceNumber = 0;
        
index 9ac08abb15be867cd69da6e466cd54523cfbf57a..db51171405c6c881a8cd0d91b0e84a2c1fa4e8b1 100644 (file)
@@ -62,21 +62,23 @@ typedef struct{
 
 static yaffsfs_Inode yaffsfs_inode[YAFFSFS_N_HANDLES];
 static yaffsfs_Handle yaffsfs_handle[YAFFSFS_N_HANDLES];
 
 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.
  */
 
 
 /*
  * yaffsfs_InitHandle
  * Inilitalise handle management on start-up.
  */
 
-static int yaffsfs_InitHandles(void)
+static void yaffsfs_InitHandles(void)
 {
        int i;
 {
        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;
        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)
 }
 
 yaffsfs_Handle *yaffsfs_GetHandlePointer(int h)
@@ -246,7 +248,7 @@ int yaffsfs_Match(YCHAR a, YCHAR b)
 
 int yaffsfs_IsPathDivider(YCHAR ch)
 {
 
 int yaffsfs_IsPathDivider(YCHAR ch)
 {
-       YCHAR *str = YAFFS_PATH_DIVIDERS;
+       const YCHAR *str = YAFFS_PATH_DIVIDERS;
 
        while(*str){
                if(*str == ch)
 
        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();
        T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: Mounting %s" TENDSTR),path));
 
        yaffsfs_Lock();
+
+       yaffsfs_InitHandles();
+
        dev = yaffsfs_FindDevice(path,&dummy);
        if(dev){
                if(!dev->isMounted){
        dev = yaffsfs_FindDevice(path,&dummy);
        if(dev){
                if(!dev->isMounted){
index 4b2ebe94176c8c29e164a840a07bf226230710cd..7c36dabdd7a7cf5a2bc0b89dc0781ca721fa3b74 100644 (file)
@@ -167,6 +167,7 @@ int yaffs_StartUp(void);
 
 /* Function only for debugging */
 void * yaffs_getdev(const YCHAR *path);
 
 /* Function only for debugging */
 void * yaffs_getdev(const YCHAR *path);
+int yaffs_DumpDevStruct(const YCHAR *path);
 
 #endif
 
 
 #endif
 
index 6ea5698b5052dd375e15bceba736a183209587cc..5db3da643403b6b9a9ad2aa4452ef1089cc73495 100644 (file)
@@ -72,9 +72,6 @@ static void yaffs_RemoveObjectFromDirectory(yaffs_Object *obj);
 static int yaffs_CheckStructures(void);
 static int yaffs_DoGenericObjectDeletion(yaffs_Object *in);
 
 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);
 
 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;
        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];
 
        __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);
 
        int x_offs = sizeof(yaffs_ObjectHeader);
        int x_size = dev->nDataBytesPerChunk - sizeof(yaffs_ObjectHeader);
 
-       __u8 * x_buffer;
+       char * x_buffer;
 
        int retval = 0;
 
 
        int retval = 0;
 
@@ -4987,11 +4984,11 @@ static int yaffs_DoXFetch(yaffs_Object *obj, const YCHAR *name, void *value, int
                        return 0;
        }
 
                        return 0;
        }
 
-       buffer = yaffs_GetTempBuffer(dev, __LINE__);
+       buffer = (char *) yaffs_GetTempBuffer(dev, __LINE__);
        if(!buffer)
                return -ENOMEM;
 
        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;
 
        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);
        }
                else
                        retval = nval_list(x_buffer, x_size, value,size);
        }
-       yaffs_ReleaseTempBuffer(dev,buffer,__LINE__);
+       yaffs_ReleaseTempBuffer(dev,(__u8 *)buffer,__LINE__);
        return retval;
 }
 
        return retval;
 }
 
index dea450f3ac7d50b00d56ae4563b3a88a0de57fe4..a2244d968ef653192b9db3a72d1b2f76f45a03cf 100644 (file)
@@ -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_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);
 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);
                                        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);
 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);
index b2fd8e47472fc545e31da2e7bfc82b846743e18c..e13dd41c5272a23dfe8bebc452f76ac02d7641c1 100644 (file)
@@ -20,6 +20,7 @@
 #include "yaffs_qsort.h"
 #include "yaffs_nand.h"
 #include "yaffs_getblockinfo.h"
 #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.
 
 /*
  * Checkpoints are really no benefit on very small partitions.