From: Charles Manning Date: Fri, 11 Aug 2017 04:28:05 +0000 (+1200) Subject: Clean up some compilation warnings for VxWorks X-Git-Tag: aleph1-release X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=c1422c27f5f17c68acf261209292c7489085df6b Clean up some compilation warnings for VxWorks Signed-off-by: Charles Manning --- diff --git a/direct/yaffs_list.h b/direct/yaffs_list.h index a7afaea..c099493 100644 --- a/direct/yaffs_list.h +++ b/direct/yaffs_list.h @@ -36,6 +36,10 @@ struct list_head { /* Initialise a static list */ +#ifdef LIST_HEAD +#undef LIST_HEAD +#endif + #define LIST_HEAD(name) \ struct list_head name = { &(name), &(name)} diff --git a/direct/ydirectenv.h b/direct/ydirectenv.h index b15147c..126b6ce 100644 --- a/direct/ydirectenv.h +++ b/direct/ydirectenv.h @@ -39,6 +39,9 @@ void yaffs_bug_fn(const char *file_name, int line_no); #define Y_LOFF_T loff_t #endif +/* Some RTOSs (eg. VxWorks) need strnlen. */ +size_t strnlen(const char *s, size_t maxlen); + #define yaffs_strcat(a, b) strcat(a, b) #define yaffs_strcpy(a, b) strcpy(a, b) #define yaffs_strncpy(a, b, c) strncpy(a, b, c) diff --git a/yaffs_endian.h b/yaffs_endian.h index d9b4e07..e2fc602 100644 --- a/yaffs_endian.h +++ b/yaffs_endian.h @@ -31,17 +31,19 @@ static inline u32 swap_u32(u32 val) static inline loff_t swap_loff_t(loff_t lval) { - u32 vall = swap_u32((u32) (lval & 0xffffffff)); + u32 vall = swap_u32(FSIZE_LOW(lval)); u32 valh; if (sizeof(loff_t) == sizeof(u32)) return (loff_t) vall; - valh = swap_u32((u32) ((lval >> 32) & 0xffffffff)); + valh = swap_u32(FSIZE_HIGH(lval)); - return (loff_t)((((u64)vall) << 32) | valh); + return FSIZE_COMBINE(vall, valh); /*NB: h and l are swapped. */ } + + struct yaffs_dev; void yaffs_do_endian_s32(struct yaffs_dev *dev, s32 *val); void yaffs_do_endian_u32(struct yaffs_dev *dev, u32 *val); diff --git a/yaffs_guts.c b/yaffs_guts.c index e95d870..44b1805 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -5158,8 +5158,9 @@ void yaffs_oh_size_load(struct yaffs_dev *dev, loff_t fsize, int do_endian) { - oh->file_size_low = (fsize & 0xFFFFFFFF); - oh->file_size_high = ((fsize >> 32) & 0xFFFFFFFF); + oh->file_size_low = FSIZE_LOW(fsize); + + oh->file_size_high = FSIZE_HIGH(fsize); if (do_endian) { yaffs_do_endian_u32(dev, &oh->file_size_low); @@ -5181,8 +5182,7 @@ loff_t yaffs_oh_to_size(struct yaffs_dev *dev, struct yaffs_obj_hdr *oh, yaffs_do_endian_u32 (dev, &low); yaffs_do_endian_u32 (dev, &high); } - retval = (((loff_t) high) << 32) | - (((loff_t) low) & 0xFFFFFFFF); + retval = FSIZE_COMBINE(high, low); } else { u32 low = oh->file_size_low; diff --git a/yaffs_guts.h b/yaffs_guts.h index 6bcf12d..974396f 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -1050,4 +1050,21 @@ void yaffs_count_blocks_by_state(struct yaffs_dev *dev, int bs[10]); int yaffs_find_chunk_in_file(struct yaffs_obj *in, int inode_chunk, struct yaffs_ext_tags *tags); +/* + * Define LOFF_T_32_BIT if a 32-bit LOFF_T is being used. + * Not serious if you get this wrong - you might just get some warnings. +*/ + +#ifdef LOFF_T_32_BIT +#define FSIZE_LOW(fsize) (fsize) +#define FSIZE_HIGH(fsize) 0 +#define FSIZE_COMBINE(high, low) (low) +#else +#define FSIZE_LOW(fsize) ((fsize) & 0xffffffff) +#define FSIZE_HIGH(fsize)(((fsize) >> 32) & 0xffffffff) +#define FSIZE_COMBINE(high, low) ((((loff_t) (high)) << 32) | \ + (((loff_t) (low)) & 0xFFFFFFFF)) +#endif + + #endif