From 1bba04f3e50aab260ca1986f410dad7899737c1f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 2 Jan 2006 14:59:11 -0500 Subject: [svn-r11852] Purpose: Code cleanup/update Description: Update compiler flags for gcc 4.1.x & start cleaning up some of the C++ compatibility Platforms tested: FreeBSD 4.11 (sleipnir) w/gcc 4.1 and/or g++ --- config/gnu-flags | 47 ++++++++++++++++++++++++++++++++++++++++++++--- src/H5A.c | 34 +++++++++++++++++----------------- src/H5FLprivate.h | 36 ++++++++++++++++++------------------ 3 files changed, 79 insertions(+), 38 deletions(-) diff --git a/config/gnu-flags b/config/gnu-flags index 85c970d..f081e55 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -181,10 +181,51 @@ esac # the information from the previous version and adding modifications to that. case "$cc_vendor-$cc_version" in -# Closer to the gcc 4.1 release, we should check for additional flags to +# Closer to the gcc 4.2 release, we should check for additional flags to # include and break it out into it's own section, like the other versions # below. -QAK - gcc-4.[01]*) + gcc-4.[12]*) + # Replace -ansi flag with -std=c99 flag + CFLAGS="`echo $CFLAGS | sed -e 's/-ansi/-std=c99/g'`" + + # Disable warnings about using 'long long' type + CFLAGS="$CFLAGS -Wno-long-long" + + # Append warning flags from gcc-3* case + CFLAGS="$CFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" + + # Append warning flags from gcc-3.2* case + CFLAGS="$CFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization -Wmultichar" + + # Enable mort format checking flags, beyond the basic -Wformat included + # in -Wall + CFLAGS="$CFLAGS -Wformat-nonliteral -Wformat-security -Wformat-y2k" + + # The "unreachable code" warning does not appear to be reliable yet... + CFLAGS="$CFLAGS -Wunreachable-code" + + # Append warning flags from gcc-3.3* case + CFLAGS="$CFLAGS -Wendif-labels" + + # Append warning flags from gcc-3.4* case + CFLAGS="$CFLAGS -Wdeclaration-after-statement -Wold-style-definition -Winvalid-pch" + + # Replace old -W flag with new -Wextra flag + CFLAGS="`echo $CFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" + + # Append more extra warning flags that only gcc4.0+ know about + CFLAGS="$CFLAGS -Wmissing-field-initializers -Wvariadic-macros" + + # Append more extra warning flags that only gcc4.1+ know about + CFLAGS="$CFLAGS -Wunsafe-loop-optimizations -Wc++-compat -Wvolatile-register-var" + + # Try out the new "stack protector" feature in gcc 4.1 + # (Strictly speaking this isn't really a "warning" flag, so it's added to + # the debugging flags) + #DEBUG_CFLAGS="$DEBUG_CFLAGS -Wstack-protector -fstack-protector-all" + ;; + + gcc-4.0*) # Replace -ansi flag with -std=c99 flag CFLAGS="`echo $CFLAGS | sed -e 's/-ansi/-std=c99/g'`" @@ -214,7 +255,7 @@ case "$cc_vendor-$cc_version" in CFLAGS="`echo $CFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" # Append more extra warning flags that only gcc4.0+ know about - CFLAGS="$CFLAGS -Wvariadic-macros" + CFLAGS="$CFLAGS -Wmissing-field-initializers -Wvariadic-macros" ;; gcc-3.4*) diff --git a/src/H5A.c b/src/H5A.c index e0a9681..d604618 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -203,9 +203,9 @@ H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") - if(NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Go do the real work for attaching the attribute to the dataset */ @@ -576,7 +576,7 @@ H5A_open(H5G_loc_t *loc, unsigned idx, hid_t dxpl_id) /* Read in attribute with H5O_read() */ H5_CHECK_OVERFLOW(idx,unsigned,int); - if(NULL == (attr = H5O_read(loc->oloc, H5O_ATTR_ID, (int)idx, NULL, dxpl_id))) + if(NULL == (attr = (H5A_t *)H5O_read(loc->oloc, H5O_ATTR_ID, (int)idx, NULL, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from dataset header") attr->initialized = TRUE; @@ -644,9 +644,9 @@ H5Awrite(hid_t attr_id, hid_t type_id, const void *buf) H5TRACE3("e","iix",attr_id,type_id,buf); /* check arguments */ - if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") @@ -732,7 +732,7 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) /* Free the previous attribute data buffer, if there is one */ if(attr->data) - H5FL_BLK_FREE(attr_buf, attr->data); + attr->data = H5FL_BLK_FREE(attr_buf, attr->data); /* Set the pointer to the attribute data to the converted information */ attr->data = tconv_buf; @@ -769,7 +769,7 @@ done: if(dst_id >= 0) (void)H5I_dec_ref(dst_id); if(bkg_buf) - H5FL_BLK_FREE(attr_buf, bkg_buf); + bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5A_write() */ @@ -802,9 +802,9 @@ H5Aread(hid_t attr_id, hid_t type_id, void *buf) H5TRACE3("e","iix",attr_id,type_id,buf); /* check arguments */ - if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") @@ -912,9 +912,9 @@ done: if(dst_id >= 0) (void)H5I_dec_ref(dst_id); if(tconv_buf) - H5FL_BLK_FREE(attr_buf, tconv_buf); + tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); if(bkg_buf) - H5FL_BLK_FREE(attr_buf, bkg_buf); + bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5A_read() */ @@ -947,7 +947,7 @@ H5Aget_space(hid_t attr_id) H5TRACE1("i","i",attr_id); /* check arguments */ - if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Copy the attribute's dataspace */ @@ -990,7 +990,7 @@ H5Aget_type(hid_t attr_id) H5TRACE1("i","i",attr_id); /* check arguments */ - if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* @@ -1108,7 +1108,7 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) H5TRACE3("Zs","izs",attr_id,buf_size,buf); /* check arguments */ - if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") if(!buf && buf_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") @@ -1165,7 +1165,7 @@ H5Aget_storage_size(hid_t attr_id) H5TRACE1("h","i",attr_id); /* Check args */ - if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") /* Set return value */ @@ -1653,7 +1653,7 @@ H5A_free(H5A_t *attr) if(H5S_close(attr->ds) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info") if(attr->data) - H5FL_BLK_FREE(attr_buf, attr->data); + attr->data = H5FL_BLK_FREE(attr_buf, attr->data); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1694,7 +1694,7 @@ H5A_close(H5A_t *attr) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") /* Free temporary buffer */ - H5FL_BLK_FREE(attr_buf, tmp_buf); + tmp_buf = H5FL_BLK_FREE(attr_buf, tmp_buf); } /* end if */ /* Free dynamicly allocated items */ diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index 325eef8..2ff31c7 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -120,10 +120,10 @@ typedef struct H5FL_reg_head_t { #define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) /* Allocate an object of type 't' */ -#define H5FL_MALLOC(t) H5FL_reg_malloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO) +#define H5FL_MALLOC(t) (t *)H5FL_reg_malloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO) /* Allocate an object of type 't' and clear it to all zeros */ -#define H5FL_CALLOC(t) H5FL_reg_calloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO) +#define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO) /* Free an object of type 't' */ #define H5FL_FREE(t,obj) H5FL_reg_free(&(H5FL_REG_NAME(t)),obj) @@ -140,8 +140,8 @@ typedef struct H5FL_reg_head_t { #define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) #define H5FL_EXTERN(t) extern H5_DLL int H5FL_REG_NAME(t) #define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) -#define H5FL_MALLOC(t) H5MM_malloc(sizeof(t)) -#define H5FL_CALLOC(t) H5MM_calloc(sizeof(t)) +#define H5FL_MALLOC(t) (t *)H5MM_malloc(sizeof(t)) +#define H5FL_CALLOC(t) (t *)H5MM_calloc(sizeof(t)) #define H5FL_FREE(t,obj) H5MM_xfree(obj) #endif /* H5_NO_REG_FREE_LISTS */ @@ -189,16 +189,16 @@ typedef struct H5FL_blk_head_t { #define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) /* Allocate an block of type 't' */ -#define H5FL_BLK_MALLOC(t,size) H5FL_blk_malloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO) +#define H5FL_BLK_MALLOC(t,size) (uint8_t *)H5FL_blk_malloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO) /* Allocate an block of type 't' and clear it to zeros */ -#define H5FL_BLK_CALLOC(t,size) H5FL_blk_calloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO) +#define H5FL_BLK_CALLOC(t,size) (uint8_t *)H5FL_blk_calloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO) /* Free a block of type 't' */ -#define H5FL_BLK_FREE(t,blk) H5FL_blk_free(&(H5FL_BLK_NAME(t)),blk) +#define H5FL_BLK_FREE(t,blk) (uint8_t *)H5FL_blk_free(&(H5FL_BLK_NAME(t)),blk) /* Re-allocate a block of type 't' */ -#define H5FL_BLK_REALLOC(t,blk,new_size) H5FL_blk_realloc(&(H5FL_BLK_NAME(t)),blk,new_size H5FL_TRACK_INFO) +#define H5FL_BLK_REALLOC(t,blk,new_size) (uint8_t *)H5FL_blk_realloc(&(H5FL_BLK_NAME(t)),blk,new_size H5FL_TRACK_INFO) /* Check if there is a free block available to re-use */ #define H5FL_BLK_AVAIL(t,size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)),size) @@ -210,10 +210,10 @@ typedef struct H5FL_blk_head_t { #define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) #define H5FL_BLK_EXTERN(t) extern H5_DLL int H5FL_BLK_NAME(t) #define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) -#define H5FL_BLK_MALLOC(t,size) H5MM_malloc(size) -#define H5FL_BLK_CALLOC(t,size) H5MM_calloc(size) -#define H5FL_BLK_FREE(t,blk) H5MM_xfree(blk) -#define H5FL_BLK_REALLOC(t,blk,new_size) H5MM_realloc(blk,new_size) +#define H5FL_BLK_MALLOC(t,size) (uint8_t *)H5MM_malloc(size) +#define H5FL_BLK_CALLOC(t,size) (uint8_t *)H5MM_calloc(size) +#define H5FL_BLK_FREE(t,blk) (uint8_t *)H5MM_xfree(blk) +#define H5FL_BLK_REALLOC(t,blk,new_size) (uint8_t *)H5MM_realloc(blk,new_size) #define H5FL_BLK_AVAIL(t,size) (FALSE) #endif /* H5_NO_BLK_FREE_LISTS */ @@ -321,16 +321,16 @@ typedef struct H5FL_seq_head_t { #define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) /* Allocate a sequence of type 't' */ -#define H5FL_SEQ_MALLOC(t,elem) H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO) +#define H5FL_SEQ_MALLOC(t,elem) (t *)H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO) /* Allocate a sequence of type 't' and clear it to all zeros */ -#define H5FL_SEQ_CALLOC(t,elem) H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO) +#define H5FL_SEQ_CALLOC(t,elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO) /* Free a sequence of type 't' */ #define H5FL_SEQ_FREE(t,obj) H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj) /* Re-allocate a sequence of type 't' */ -#define H5FL_SEQ_REALLOC(t,obj,new_elem) H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem H5FL_TRACK_INFO) +#define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem H5FL_TRACK_INFO) #else /* H5_NO_SEQ_FREE_LISTS */ /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ @@ -339,10 +339,10 @@ typedef struct H5FL_seq_head_t { #define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) #define H5FL_SEQ_EXTERN(t) extern H5_DLL int H5FL_SEQ_NAME(t) #define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) -#define H5FL_SEQ_MALLOC(t,elem) H5MM_malloc((elem)*sizeof(t)) -#define H5FL_SEQ_CALLOC(t,elem) H5MM_calloc((elem)*sizeof(t)) +#define H5FL_SEQ_MALLOC(t,elem) (t *)H5MM_malloc((elem)*sizeof(t)) +#define H5FL_SEQ_CALLOC(t,elem) (t *)H5MM_calloc((elem)*sizeof(t)) #define H5FL_SEQ_FREE(t,obj) H5MM_xfree(obj) -#define H5FL_SEQ_REALLOC(t,obj,new_elem) H5MM_realloc(obj,(new_elem)*sizeof(t)) +#define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5MM_realloc(obj,(new_elem)*sizeof(t)) #endif /* H5_NO_SEQ_FREE_LISTS */ /* Data structure for free list block factory */ -- cgit v0.12