diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-04-23 05:06:20 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-04-23 05:06:20 (GMT) |
commit | fad680156919cf7261a8c1833fc5efdd3346cc11 (patch) | |
tree | 2d0bc9e66ec7ace6bb163b8d3e49254a272a2588 /src | |
parent | 562cdc22ffd0a32a4b7ce105cb4c2878ac342c05 (diff) | |
download | hdf5-fad680156919cf7261a8c1833fc5efdd3346cc11.zip hdf5-fad680156919cf7261a8c1833fc5efdd3346cc11.tar.gz hdf5-fad680156919cf7261a8c1833fc5efdd3346cc11.tar.bz2 |
[svn-r8412] Purpose:
Code cleanup
Description:
Run lint on module
Platforms tested:
PC-Lint
Too minor to require h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Tenum.c | 138 | ||||
-rw-r--r-- | src/H5Tpkg.h | 6 | ||||
-rw-r--r-- | src/H5Tpublic.h | 4 | ||||
-rwxr-xr-x | src/hdf5.lnt | 4 |
4 files changed, 78 insertions, 74 deletions
diff --git a/src/H5Tenum.c b/src/H5Tenum.c index fd31375..7ea1b10 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -37,7 +37,7 @@ static herr_t H5T_init_enum_interface(void); H5FL_EXTERN(H5T_t); /* Static local functions */ -static char *H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, +static char *H5T_enum_nameof(H5T_t *dt, const void *value, char *name/*out*/, size_t size); static herr_t H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/); @@ -59,9 +59,9 @@ DESCRIPTION static herr_t H5T_init_enum_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_enum_interface); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_enum_interface) - FUNC_LEAVE_NOAPI(H5T_init()); + FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_enum_interface() */ @@ -89,22 +89,22 @@ H5Tenum_create(hid_t parent_id) H5T_t *dt = NULL; /*new enumeration data type */ hid_t ret_value; /*return value */ - FUNC_ENTER_API(H5Tenum_create, FAIL); + FUNC_ENTER_API(H5Tenum_create, FAIL) H5TRACE1("i","i",parent_id); /* Check args */ if (NULL==(parent=H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_INTEGER!=parent->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type") /* Build new type */ if((dt=H5T_enum_create(parent))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot create enum type"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot create enum type") /* Atomize the type */ if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -127,17 +127,17 @@ done: *------------------------------------------------------------------------- */ H5T_t * -H5T_enum_create(H5T_t *parent) +H5T_enum_create(const H5T_t *parent) { H5T_t *ret_value; /*new enumeration data type */ - FUNC_ENTER_NOAPI(H5T_enum_create, NULL); + FUNC_ENTER_NOAPI(H5T_enum_create, NULL) assert(parent); /* Build new type */ if (NULL==(ret_value = H5FL_CALLOC(H5T_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") ret_value->type = H5T_ENUM; ret_value->parent = H5T_copy(parent, H5T_COPY_ALL); assert(ret_value->parent); @@ -145,7 +145,7 @@ H5T_enum_create(H5T_t *parent) ret_value->ent.header = HADDR_UNDEF; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -171,30 +171,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Tenum_insert(hid_t type, const char *name, void *value) +H5Tenum_insert(hid_t type, const char *name, const void *value) { H5T_t *dt=NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Tenum_insert, FAIL); + FUNC_ENTER_API(H5Tenum_insert, FAIL) H5TRACE3("e","isx",type,name,value); /* Check args */ if (NULL==(dt=H5I_object_verify(type,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 (H5T_ENUM!=dt->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified") /* Do work */ if (H5T_enum_insert(dt, name, value)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -218,14 +218,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_enum_insert(H5T_t *dt, const char *name, void *value) +H5T_enum_insert(H5T_t *dt, const char *name, const void *value) { unsigned i; char **names=NULL; uint8_t *values=NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5T_enum_insert, FAIL); + FUNC_ENTER_NOAPI(H5T_enum_insert, FAIL) assert(dt); assert(name && *name); @@ -234,20 +234,20 @@ H5T_enum_insert(H5T_t *dt, const char *name, void *value) /* The name and value had better not already exist */ for (i=0; i<dt->u.enumer.nmembs; i++) { if (!HDstrcmp(dt->u.enumer.name[i], name)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition") if (!HDmemcmp(dt->u.enumer.value+i*dt->size, value, dt->size)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition") } /* Increase table sizes */ if (dt->u.enumer.nmembs >= dt->u.enumer.nalloc) { - int n = MAX(32, 2*dt->u.enumer.nalloc); + unsigned n = MAX(32, 2*dt->u.enumer.nalloc); if (NULL==(names=H5MM_realloc(dt->u.enumer.name, n*sizeof(char*)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") dt->u.enumer.name = names; if (NULL==(values=H5MM_realloc(dt->u.enumer.value, n*dt->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") dt->u.enumer.value = values; dt->u.enumer.nalloc = n; } @@ -259,7 +259,7 @@ H5T_enum_insert(H5T_t *dt, const char *name, void *value) HDmemcpy(dt->u.enumer.value+i*dt->size, value, dt->size); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -294,22 +294,22 @@ H5Tget_member_value(hid_t type, unsigned membno, void *value/*out*/) H5T_t *dt=NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Tget_member_value, FAIL); + FUNC_ENTER_API(H5Tget_member_value, FAIL) H5TRACE3("e","iIux",type,membno,value); if (NULL==(dt=H5I_object_verify(type,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 (H5T_ENUM!=dt->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class") if (membno>=dt->u.enumer.nmembs) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer") if (H5T_get_member_value(dt, membno, value)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get member value"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get member value") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -332,11 +332,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_get_member_value(H5T_t *dt, unsigned membno, void *value/*out*/) +H5T_get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5T_get_member_value, FAIL); + FUNC_ENTER_NOAPI(H5T_get_member_value, FAIL) assert(dt); assert(value); @@ -344,7 +344,7 @@ H5T_get_member_value(H5T_t *dt, unsigned membno, void *value/*out*/) HDmemcpy(value, dt->u.enumer.value + membno*dt->size, dt->size); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -372,29 +372,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Tenum_nameof(hid_t type, void *value, char *name/*out*/, size_t size) +H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, size_t size) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Tenum_nameof, FAIL); + FUNC_ENTER_API(H5Tenum_nameof, FAIL) H5TRACE4("e","ixxz",type,value,name,size); /* Check args */ if (NULL==(dt=H5I_object_verify(type,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 (H5T_ENUM!=dt->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied") if (!name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied") if (NULL==H5T_enum_nameof(dt, value, name, size)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -424,13 +424,13 @@ done: *------------------------------------------------------------------------- */ static char * -H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size) +H5T_enum_nameof(H5T_t *dt, const void *value, char *name/*out*/, size_t size) { - int lt, md, rt; /*indices for binary search */ + unsigned lt, md=0, rt; /*indices for binary search */ int cmp=(-1); /*comparison result */ char *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5T_enum_nameof, NULL); + FUNC_ENTER_NOAPI(H5T_enum_nameof, NULL) /* Check args */ assert(dt && H5T_ENUM==dt->type); @@ -440,13 +440,13 @@ H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size) /* Sanity check */ if (dt->u.enumer.nmembs == 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "datatype has no members"); + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "datatype has no members") /* Do a binary search over the values to find the correct one */ - H5T_sort_value(dt, NULL); + if(H5T_sort_value(dt, NULL)<0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, NULL, "value sort failed") lt = 0; rt = dt->u.enumer.nmembs; - md = -1; while (lt<rt) { md = (lt+rt)/2; @@ -461,20 +461,20 @@ H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size) } /* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */ if (cmp!=0) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "value is currently not defined"); + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "value is currently not defined") /* Save result name */ if (!name && NULL==(name=H5MM_malloc(HDstrlen(dt->u.enumer.name[md])+1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDstrncpy(name, dt->u.enumer.name[md], size); if (HDstrlen(dt->u.enumer.name[md])>=size) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated"); + HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated") /* Set return value */ ret_value=name; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -503,24 +503,24 @@ H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/) H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Tenum_valueof, FAIL); + FUNC_ENTER_API(H5Tenum_valueof, FAIL) H5TRACE3("e","isx",type,name,value); /* Check args */ if (NULL==(dt=H5I_object_verify(type,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 (H5T_ENUM!=dt->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer") if (H5T_enum_valueof(dt, name, value)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -546,11 +546,11 @@ done: static herr_t H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/) { - int lt, md, rt; /*indices for binary search */ + unsigned lt, md=0, rt; /*indices for binary search */ int cmp=(-1); /*comparison result */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5T_enum_valueof, FAIL); + FUNC_ENTER_NOAPI(H5T_enum_valueof, FAIL) /* Check args */ assert(dt && H5T_ENUM==dt->type); @@ -559,13 +559,13 @@ H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/) /* Sanity check */ if (dt->u.enumer.nmembs == 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "datatype has no members"); + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "datatype has no members") /* Do a binary search over the names to find the correct one */ - H5T_sort_name(dt, NULL); + if(H5T_sort_name(dt, NULL)<0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") lt = 0; rt = dt->u.enumer.nmembs; - md = -1; while (lt<rt) { md = (lt+rt)/2; @@ -580,11 +580,11 @@ H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/) } /* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */ if (cmp!=0) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type") HDmemcpy(value, dt->u.enumer.value+md*dt->size, dt->size); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index e3e6226..1ecf0f3 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -322,13 +322,13 @@ H5_DLL herr_t H5T_free(H5T_t *dt); H5_DLL H5T_sign_t H5T_get_sign(H5T_t const *dt); H5_DLL H5T_t *H5T_get_super(H5T_t *dt); H5_DLL char *H5T_get_member_name(H5T_t const *dt, unsigned membno); -H5_DLL herr_t H5T_get_member_value(H5T_t *dt, unsigned membno, void *value); +H5_DLL herr_t H5T_get_member_value(const H5T_t *dt, unsigned membno, void *value); H5_DLL H5T_t *H5T_get_member_type(H5T_t *dt, unsigned membno); H5_DLL int H5T_get_nmembers(const H5T_t *dt); H5_DLL herr_t H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member); -H5_DLL H5T_t *H5T_enum_create(H5T_t *parent); -H5_DLL herr_t H5T_enum_insert(H5T_t *dt, const char *name, void *value); +H5_DLL H5T_t *H5T_enum_create(const H5T_t *parent); +H5_DLL herr_t H5T_enum_insert(H5T_t *dt, const char *name, const void *value); H5_DLL int H5T_get_array_ndims(H5T_t *dt); H5_DLL int H5T_get_array_dims(H5T_t *dt, hsize_t dims[], int perm[]); H5_DLL herr_t H5T_sort_value(H5T_t *dt, int *map); diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 13c8a33..442407f 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -485,8 +485,8 @@ H5_DLL herr_t H5Tpack(hid_t type_id); /* Operations defined on enumeration datatypes */ H5_DLL hid_t H5Tenum_create(hid_t base_id); -H5_DLL herr_t H5Tenum_insert(hid_t type, const char *name, void *value); -H5_DLL herr_t H5Tenum_nameof(hid_t type, void *value, char *name/*out*/, +H5_DLL herr_t H5Tenum_insert(hid_t type, const char *name, const void *value); +H5_DLL herr_t H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, size_t size); H5_DLL herr_t H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/); diff --git a/src/hdf5.lnt b/src/hdf5.lnt index b6fe223..72d29b0 100755 --- a/src/hdf5.lnt +++ b/src/hdf5.lnt @@ -1,3 +1,6 @@ +// Define the __FUNCTION__ so we don't get warnings about using it. +-d__FUNCTION__="NoFunctionName" + // Turn off warnings about not using the return value from these functions: -esym(534, HDfprintf, HDsnprintf, HDvsnprintf) -esym(534, H5E_clear, H5E_push) @@ -91,6 +94,7 @@ H5FL.c H5FO.c + H5Tenum.c H5Tfields.c H5Tfixed.c H5Tfloat.c |