From: Charles Manning Date: Thu, 22 Jul 2010 00:13:33 +0000 (+1200) Subject: yaffs Clean up WinCE compilation issues X-Git-Tag: pre-name-change~40 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=f792554ed6d0b514dfb040097033417d8e41f420 yaffs Clean up WinCE compilation issues Signed-off-by: Charles Manning --- diff --git a/direct/basic-test/yramsim.c b/direct/basic-test/yramsim.c index a791791..69b5b78 100644 --- a/direct/basic-test/yramsim.c +++ b/direct/basic-test/yramsim.c @@ -7,13 +7,6 @@ #include "yaffs_nandif.h" -#ifdef __WINCE__ -#include -#else -#define DebugBreak() do { } while(0) -#endif - - #define DATA_SIZE 2048 #define SPARE_SIZE 64 #define PAGE_SIZE (DATA_SIZE + SPARE_SIZE) @@ -47,17 +40,14 @@ static void CheckInitialised(void) static int yramsim_EraseBlockInternal(SymData *sym, unsigned blockId,int force) { if(blockId < 0 || blockId >= sym->nBlocks){ - DebugBreak(); return 0; } if(!sym->blockList[blockId]){ - DebugBreak(); return 0; } if(!force && !sym->blockList[blockId]->blockOk){ - DebugBreak(); return 0; } @@ -101,7 +91,6 @@ static int yramsim_ReadChunk (yaffs_Device *dev, unsigned pageId, spareLength > SPARE_SIZE || !eccStatus || !blockList[blockId]->blockOk){ - DebugBreak(); return 0; } @@ -136,7 +125,6 @@ static int yramsim_WriteChunk (yaffs_Device *dev,unsigned pageId, dataLength >DATA_SIZE || spareLength > SPARE_SIZE || !blockList[blockId]->blockOk){ - DebugBreak(); return 0; } @@ -167,7 +155,6 @@ static int yramsim_CheckBlockOk(yaffs_Device *dev,unsigned blockId) SymData *sym = DevToSym(dev); Block **blockList = sym->blockList; if(blockId >= sym->nBlocks){ - DebugBreak(); return 0; } @@ -179,7 +166,6 @@ static int yramsim_MarkBlockBad(yaffs_Device *dev,unsigned blockId) SymData *sym = DevToSym(dev); Block **blockList = sym->blockList; if(blockId >= sym->nBlocks){ - DebugBreak(); return 0; } diff --git a/direct/yaffs_nandif.c b/direct/yaffs_nandif.c index 6f36eb7..e5358a1 100644 --- a/direct/yaffs_nandif.c +++ b/direct/yaffs_nandif.c @@ -22,7 +22,7 @@ #include "yramsim.h" #include "yaffs_trace.h" - +#include "yaffsfs.h" /* NB For use with inband tags.... diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 9fc4417..fc68b96 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -1186,7 +1186,7 @@ int yaffs_fstat(int fd, struct yaffs_stat *buf) return retVal; } - +#ifndef CONFIG_YAFFS_WINCE /* xattrib functions */ @@ -1440,6 +1440,7 @@ int yaffs_fremovexattr(int fd, const char *name) return retVal; } +#endif #ifdef CONFIG_YAFFS_WINCE int yaffs_get_wince_times(int fd, unsigned *wctime, unsigned *watime, unsigned *wmtime) diff --git a/yaffs_guts.c b/yaffs_guts.c index d65c0ca..b8a11b5 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -4896,7 +4896,7 @@ int yaffs_GetAttributes(yaffs_Object *obj, struct iattr *attr) #endif -static int yaffs_DoXMod(yaffs_Object *obj, int set, const char *name, const void *value, int size, int flags) +static int yaffs_DoXMod(yaffs_Object *obj, int set, const YCHAR *name, const void *value, int size, int flags) { yaffs_XAttrMod xmod; @@ -4935,7 +4935,7 @@ static int yaffs_ApplyXMod(yaffs_Device *dev, char *buffer, yaffs_XAttrMod *xmod return retval; } -static int yaffs_DoXFetch(yaffs_Object *obj, const char *name, void *value, int size) +static int yaffs_DoXFetch(yaffs_Object *obj, const YCHAR *name, void *value, int size) { char *buffer = NULL; int result; @@ -4971,17 +4971,17 @@ static int yaffs_DoXFetch(yaffs_Object *obj, const char *name, void *value, int return retval; } -int yaffs_SetXAttribute(yaffs_Object *obj, const char *name, const void * value, int size, int flags) +int yaffs_SetXAttribute(yaffs_Object *obj, const YCHAR *name, const void * value, int size, int flags) { return yaffs_DoXMod(obj, 1, name, value, size, flags); } -int yaffs_RemoveXAttribute(yaffs_Object *obj, const char *name) +int yaffs_RemoveXAttribute(yaffs_Object *obj, const YCHAR *name) { return yaffs_DoXMod(obj, 0, name, NULL, 0, 0); } -int yaffs_GetXAttribute(yaffs_Object *obj, const char *name, void *value, int size) +int yaffs_GetXAttribute(yaffs_Object *obj, const YCHAR *name, void *value, int size) { return yaffs_DoXFetch(obj, name, value, size); } diff --git a/yaffs_guts.h b/yaffs_guts.h index b7e2f4b..90c3022 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -517,7 +517,7 @@ typedef struct { struct yaffs_DeviceParamStruct { - const char *name; + const YCHAR *name; /* * Entry parameters set up way early. Yaffs sets up the rest. @@ -822,7 +822,7 @@ struct yaffs_ShadowFixerStruct { /* Structure for doing xattr modifications */ typedef struct { int set; /* If 0 then this is a deletion */ - const char *name; + const YCHAR *name; const void *data; int size; int flags; diff --git a/yaffs_nameval.c b/yaffs_nameval.c index 4835ccf..4b28513 100644 --- a/yaffs_nameval.c +++ b/yaffs_nameval.c @@ -21,6 +21,8 @@ * nbytes value. * ---------- * total size stored in record size + * + * This code has not been tested with unicode yet. */ @@ -28,7 +30,7 @@ #include "yportenv.h" -static int nval_find(const char *xb, int xb_size, const char *name, +static int nval_find(const char *xb, int xb_size, const YCHAR *name, int *exist_size) { int pos=0; @@ -36,7 +38,7 @@ static int nval_find(const char *xb, int xb_size, const char *name, memcpy(&size,xb,sizeof(int)); while(size > 0 && (size < xb_size) && (pos + size < xb_size)){ - if(strncmp(xb+pos+sizeof(int),name,size) == 0){ + if(yaffs_strncmp((YCHAR *)(xb+pos+sizeof(int)),name,size) == 0){ if(exist_size) *exist_size = size; return pos; @@ -68,7 +70,7 @@ static int nval_used(const char *xb, int xb_size) return pos; } -int nval_del(char *xb, int xb_size, const char *name) +int nval_del(char *xb, int xb_size, const YCHAR *name) { int pos = nval_find(xb, xb_size, name, NULL); int size; @@ -83,10 +85,10 @@ int nval_del(char *xb, int xb_size, const char *name) return -ENODATA; } -int nval_set(char *xb, int xb_size, const char *name, const char *buf, int bsize, int flags) +int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf, int bsize, int flags) { int pos; - int namelen = strnlen(name,xb_size); + int namelen = yaffs_strnlen(name,xb_size); int reclen; int size_exist = 0; int space; @@ -116,13 +118,13 @@ int nval_set(char *xb, int xb_size, const char *name, const char *buf, int bsize memcpy(xb + pos,&reclen,sizeof(int)); pos +=sizeof(int); - strncpy(xb + pos, name, reclen); + yaffs_strncpy((YCHAR *)(xb + pos), name, reclen); pos+= (namelen+1); memcpy(xb + pos,buf,bsize); return 0; } -int nval_get(const char *xb, int xb_size, const char *name, char *buf, int bsize) +int nval_get(const char *xb, int xb_size, const YCHAR *name, char *buf, int bsize) { int pos = nval_find(xb,xb_size,name,NULL); int size; @@ -166,12 +168,16 @@ int nval_list(const char *xb, int xb_size, char *buf, int bsize) while(size > sizeof(int) && size <= xb_size && (pos + size) < xb_size && !filled){ pos+= sizeof(int); size-=sizeof(int); - name_len = strnlen(xb + pos, size); + name_len = yaffs_strnlen((YCHAR *)(xb + pos), size); if(ncopied + name_len + 1 < bsize){ - memcpy(buf,xb+pos,name_len); + memcpy(buf,xb+pos,name_len * sizeof(YCHAR)); buf+= name_len; *buf = '\0'; buf++; + if(sizeof(YCHAR) > 1){ + *buf = '\0'; + buf++; + } ncopied += (name_len+1); } else filled = 1; diff --git a/yaffs_nameval.h b/yaffs_nameval.h index 102c1c0..a9d4a0a 100644 --- a/yaffs_nameval.h +++ b/yaffs_nameval.h @@ -1,9 +1,25 @@ +/* + * 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. + */ #ifndef __NAMEVAL_H__ #define __NAMEVAL_H__ -int nval_del(char *xb, int xb_size, const char *name); -int nval_set(char *xb, int xb_size, const char *name, const char *buf, int bsize, int flags); -int nval_get(const char *xb, int xb_size, const char *name, char *buf, int bsize); +#include "yportenv.h" + +int nval_del(char *xb, int xb_size, const YCHAR *name); +int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf, int bsize, int flags); +int nval_get(const char *xb, int xb_size, const YCHAR *name, char *buf, int bsize); int nval_list(const char *xb, int xb_size, char *buf, int bsize); int nval_load(char *xb, int xb_size, const char *src, int src_size); int nval_save(const char *xb, int xb_size, char *dest, int dest_size); diff --git a/yaffs_verify.c b/yaffs_verify.c index b8083ad..4511c0f 100644 --- a/yaffs_verify.c +++ b/yaffs_verify.c @@ -621,6 +621,7 @@ int yaffs_VerifyFileSanity(yaffs_Object *in) return failed ? YAFFS_FAIL : YAFFS_OK; #else + in=in; return YAFFS_OK; #endif }