From 85637509083b9a0cc9b90f86865613a21a8d3968 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 4 Sep 2003 09:40:21 -0500 Subject: [svn-r7444] Purpose: Code cleanup Description: More de-linting Platforms tested: FreeBSD 4.9 (sleipnir) Too small to need h5committest --- src/H5Tnative.c | 178 +++++++++++++++++++++++++++++--------------------------- src/H5Toffset.c | 46 ++++++++------- src/hdf5.lnt | 2 + 3 files changed, 117 insertions(+), 109 deletions(-) diff --git a/src/H5Tnative.c b/src/H5Tnative.c index a5005d4..cf6a953 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -23,12 +23,12 @@ /* (Put before include files to avoid problems with inline functions) */ #define PABLO_MASK H5Tnative_mask -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5Pprivate.h" /*property list */ -#include "H5MMprivate.h" /*memory management */ -#include "H5Tpkg.h" /*data-type functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /* Datatypes */ /* Interface initialization */ static int interface_initialize_g = 0; @@ -62,9 +62,9 @@ DESCRIPTION static herr_t H5T_init_native_interface(void) { - FUNC_ENTER_NOINIT(H5T_init_native_interface); + FUNC_ENTER_NOINIT(H5T_init_native_interface) - FUNC_LEAVE_NOAPI(H5T_init()); + FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_native_interface() */ @@ -108,31 +108,32 @@ H5Tget_native_type(hid_t type_id, H5T_direction_t direction) size_t comp_size=0; /* Compound datatype's size */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Tget_native_type, FAIL); + FUNC_ENTER_API(H5Tget_native_type, FAIL) H5TRACE2("i","iTd",type_id,direction); /* check argument */ if(NULL==(dt=H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if(direction!=H5T_DIR_DEFAULT && direction!=H5T_DIR_ASCEND && direction!=H5T_DIR_DESCEND) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not valid direction value"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not valid direction value") if((new_dt = H5T_get_native_type(dt, direction, NULL, NULL, &comp_size))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot retrieve native type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot retrieve native type") if((ret_value=H5I_register(H5I_DATATYPE, new_dt)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type") done: /* Error cleanup */ if(ret_value<0) { if(new_dt) - H5T_close(new_dt); + if(H5T_close(new_dt)<0) + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -165,15 +166,15 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig int i; /* Local index variable */ H5T_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5T_get_native_type, NULL); + FUNC_ENTER_NOAPI(H5T_get_native_type, NULL) assert(dtype); if((h5_class = H5T_get_class(dtype))<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class") if((size = H5T_get_size(dtype))==0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid size"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid size") switch(h5_class) { case H5T_INTEGER: @@ -181,31 +182,31 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig H5T_sign_t sign; /* Signedness of integer type */ if((sign = H5T_get_sign(dtype))==H5T_SGN_ERROR) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess") if((ret_value = H5T_get_native_integer(size, sign, direction, struct_align, offset, comp_size))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type") } break; case H5T_FLOAT: if((ret_value = H5T_get_native_float(size, direction, struct_align, offset, comp_size))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") break; case H5T_STRING: if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") if(H5T_IS_VL_STRING(dtype)) { /* Update size, offset and compound alignment for parent. */ if(H5T_cmp_offset(comp_size, offset, sizeof(char *), 1, H5T_POINTER_COMP_ALIGN_g, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } else { /* Update size, offset and compound alignment for parent. */ if(H5T_cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } break; @@ -215,7 +216,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig case H5T_BITFIELD: case H5T_OPAQUE: if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") break; @@ -226,11 +227,11 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig int not_equal; if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* Decide if the data type is object or dataset region reference. */ if(NULL==(dt=H5I_object(H5T_STD_REF_OBJ_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") not_equal = H5T_cmp(ret_value, dt); /* Update size, offset and compound alignment for parent. */ @@ -243,7 +244,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig } if(H5T_cmp_offset(comp_size, offset, ref_size, 1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } break; @@ -257,28 +258,29 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig char **comp_mname; /* List of member names in compound type */ if((nmemb = H5T_get_nmembers(dtype))<=0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member") - if((memb_list = (H5T_t**)H5MM_malloc(nmemb*sizeof(H5T_t*)))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory"); - if((memb_offset = (size_t*)H5MM_calloc(nmemb*sizeof(size_t)))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory"); - if((comp_mname = (char**)H5MM_malloc(nmemb*sizeof(char*)))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory"); + H5_CHECK_OVERFLOW(nmemb,int,size_t); + if((memb_list = (H5T_t**)H5MM_malloc((size_t)nmemb*sizeof(H5T_t*)))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if((memb_offset = (size_t*)H5MM_calloc((size_t)nmemb*sizeof(size_t)))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if((comp_mname = (char**)H5MM_malloc((size_t)nmemb*sizeof(char*)))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") /* Construct child compound type and retrieve a list of their IDs, offsets, total size, and alignment for compound type. */ for(i=0; i0); @@ -637,16 +641,16 @@ H5T_get_native_integer(size_t size, H5T_sign_t sign, H5T_direction_t direction, /* Create new native type */ assert(tid>=0); if(NULL==(dt=H5I_object(tid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* compute size and offset of compound type member. */ if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -681,7 +685,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig } match=H5T_NATIVE_FLOAT_MATCH_UNKNOWN; H5T_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5T_get_native_integer, NULL); + FUNC_ENTER_NOAPI(H5T_get_native_integer, NULL) assert(size>0); @@ -752,16 +756,16 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig /* Create new native type */ assert(tid>=0); if(NULL==(dt=H5I_object(tid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* compute offset of compound type member. */ if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -789,7 +793,7 @@ H5T_cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5T_cmp_offset, FAIL); + FUNC_ENTER_NOAPI(H5T_cmp_offset, FAIL) if(offset && comp_size) { if(align>1 && *comp_size%align) { @@ -807,6 +811,6 @@ H5T_cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, *struct_align = align; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } diff --git a/src/H5Toffset.c b/src/H5Toffset.c index 36a806d..f4151a3 100644 --- a/src/H5Toffset.c +++ b/src/H5Toffset.c @@ -19,13 +19,15 @@ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5Tpkg.h" /*data-type functions */ - +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ #define PABLO_MASK H5Toffset_mask +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ + /* Interface initialization */ static int interface_initialize_g = 0; #define INTERFACE_INIT H5T_init_offset_interface @@ -51,9 +53,9 @@ DESCRIPTION static herr_t H5T_init_offset_interface(void) { - FUNC_ENTER_NOINIT(H5T_init_offset_interface); + FUNC_ENTER_NOINIT(H5T_init_offset_interface) - FUNC_LEAVE_NOAPI(H5T_init()); + FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_offset_interface() */ @@ -97,22 +99,22 @@ H5Tget_offset(hid_t type_id) H5T_t *dt = NULL; int ret_value; - FUNC_ENTER_API(H5Tget_offset, -1); + FUNC_ENTER_API(H5Tget_offset, -1) H5TRACE1("Is","i",type_id); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") while (dt->parent) dt = dt->parent; /*defer to parent*/ if (!H5T_IS_ATOMIC(dt)) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Offset */ ret_value = (int)dt->u.atomic.offset; done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -161,27 +163,27 @@ H5Tset_offset(hid_t type_id, size_t offset) H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Tset_offset, FAIL); + FUNC_ENTER_API(H5Tset_offset, FAIL) H5TRACE2("e","iz",type_id,offset); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") if (H5T_STATE_TRANSIENT!=dt->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (H5T_STRING == dt->type && offset != 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type") if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") if (H5T_COMPOUND==dt->type || H5T_REFERENCE==dt->type || H5T_OPAQUE==dt->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype") /* Do the real work */ if (H5T_set_offset(dt, offset)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -229,7 +231,7 @@ H5T_set_offset(H5T_t *dt, size_t offset) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5T_set_offset, FAIL); + FUNC_ENTER_NOAPI(H5T_set_offset, FAIL) /* Check args */ assert(dt); @@ -241,7 +243,7 @@ H5T_set_offset(H5T_t *dt, size_t offset) if (dt->parent) { if (H5T_set_offset(dt->parent, offset)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type") /* Adjust size of datatype appropriately */ if(dt->type==H5T_ARRAY) @@ -255,6 +257,6 @@ H5T_set_offset(H5T_t *dt, size_t offset) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } diff --git a/src/hdf5.lnt b/src/hdf5.lnt index d5ae28b..364c011 100755 --- a/src/hdf5.lnt +++ b/src/hdf5.lnt @@ -91,6 +91,8 @@ H5FL.c H5FO.c + H5Tnative.c + H5Toffset.c H5Topaque.c H5Torder.c H5Tpad.c -- cgit v0.12