summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2012-10-29 18:59:05 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2012-10-29 18:59:05 (GMT)
commit0cf58a4755eb6f3e7be64b0f05f2bb8ef6f7ad0d (patch)
tree7f5576b9ed8e414606093b6872ced10dd0f5bf0e /hl
parent78b07da7aea98598a74bce25335b9435aa29cdb9 (diff)
downloadhdf5-0cf58a4755eb6f3e7be64b0f05f2bb8ef6f7ad0d.zip
hdf5-0cf58a4755eb6f3e7be64b0f05f2bb8ef6f7ad0d.tar.gz
hdf5-0cf58a4755eb6f3e7be64b0f05f2bb8ef6f7ad0d.tar.bz2
[svn-r22987] ported revisions from 22742 to 22986 from the trunk
Diffstat (limited to 'hl')
-rw-r--r--hl/CMakeLists.txt5
-rw-r--r--hl/c++/src/Makefile.in2
-rw-r--r--hl/fortran/src/Makefile.in2
-rw-r--r--hl/src/H5LTanalyze.c42
-rw-r--r--hl/src/H5LTanalyze.l1
-rw-r--r--hl/src/H5TB.c446
-rw-r--r--hl/src/H5TBpublic.h4
-rw-r--r--hl/src/Makefile.in2
-rw-r--r--hl/test/test_image.c2
-rw-r--r--hl/test/test_lite.c5
10 files changed, 290 insertions, 221 deletions
diff --git a/hl/CMakeLists.txt b/hl/CMakeLists.txt
index d1db6ca..e66329e 100644
--- a/hl/CMakeLists.txt
+++ b/hl/CMakeLists.txt
@@ -2,6 +2,11 @@ cmake_minimum_required (VERSION 2.8.6)
PROJECT (HDF5_HL C CXX)
#-----------------------------------------------------------------------------
+# Apply Definitions to compiler in this directory and below
+#-----------------------------------------------------------------------------
+ADD_DEFINITIONS (${HDF5_EXTRA_C_FLAGS})
+
+#-----------------------------------------------------------------------------
# Shared Libs
#-----------------------------------------------------------------------------
IF (BUILD_SHARED_LIBS)
diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in
index 9f5cad5..93e3942 100644
--- a/hl/c++/src/Makefile.in
+++ b/hl/c++/src/Makefile.in
@@ -458,7 +458,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog
# Add libtool shared library version numbers to the HDF5 library
# See libtool versioning documentation online.
LT_VERS_INTERFACE = 6
-LT_VERS_REVISION = 118
+LT_VERS_REVISION = 122
LT_VERS_AGE = 0
# Include src directory
diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in
index 4443e72..d2e60b8 100644
--- a/hl/fortran/src/Makefile.in
+++ b/hl/fortran/src/Makefile.in
@@ -474,7 +474,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog
# Add libtool shared library version numbers to the HDF5 library
# See libtool versioning documentation online.
LT_VERS_INTERFACE = 6
-LT_VERS_REVISION = 118
+LT_VERS_REVISION = 122
LT_VERS_AGE = 0
INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \
-I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src
diff --git a/hl/src/H5LTanalyze.c b/hl/src/H5LTanalyze.c
index 767dfd7..5ec795b 100644
--- a/hl/src/H5LTanalyze.c
+++ b/hl/src/H5LTanalyze.c
@@ -38,7 +38,7 @@
#define yywrap H5LTyywrap
#line 20 "H5LTanalyze.c"
-/* A lexical scanner generated by flex */
+/* A lexical scanner generated by flex*/
/* Scanner skeleton version:
* $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
@@ -51,7 +51,7 @@
#include <stdio.h>
#ifdef H5_HAVE_UNISTD_H
#include <unistd.h>
-#endif
+#endif
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
@@ -175,6 +175,15 @@ extern FILE *yyin, *yyout;
#define unput(c) yyunput( c, yytext_ptr )
+/* Some routines like yy_flex_realloc() are emitted as static but are
+ not called by all lexers. This generates warnings in some compilers,
+ notably GCC. Arrange to suppress these. */
+#ifdef __GNUC__
+#define YY_MAY_BE_UNUSED __attribute__((unused))
+#else
+#define YY_MAY_BE_UNUSED
+#endif
+
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
* flex-generated scanners to compile on their own).
@@ -281,7 +290,7 @@ YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )) YY_MAY_BE_UNUSED;
static void yy_flex_free YY_PROTO(( void * ));
#define yy_new_buffer yy_create_buffer
@@ -849,10 +858,10 @@ hbool_t first_quote = 1;
/* For Lex and Yacc */
/*int input_len;
char *myinput;*/
-
+
#define TAG_STRING 1
-#line 834 "H5LTanalyze.c"
+#line 843 "H5LTanalyze.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -1006,7 +1015,7 @@ YY_DECL
#line 76 "H5LTanalyze.l"
-#line 988 "H5LTanalyze.c"
+#line 997 "H5LTanalyze.c"
if ( yy_init )
{
@@ -1288,17 +1297,17 @@ YY_RULE_SETUP
case 40:
YY_RULE_SETUP
#line 121 "H5LTanalyze.l"
-{return token(H5T_STR_NULLTERM_TOKEN);}
+{return token(H5T_STR_NULLTERM_TOKEN);}
YY_BREAK
case 41:
YY_RULE_SETUP
#line 122 "H5LTanalyze.l"
-{return token(H5T_STR_NULLPAD_TOKEN);}
+{return token(H5T_STR_NULLPAD_TOKEN);}
YY_BREAK
case 42:
YY_RULE_SETUP
#line 123 "H5LTanalyze.l"
-{return token(H5T_STR_SPACEPAD_TOKEN);}
+{return token(H5T_STR_SPACEPAD_TOKEN);}
YY_BREAK
case 43:
YY_RULE_SETUP
@@ -1363,12 +1372,12 @@ YY_RULE_SETUP
case 55:
YY_RULE_SETUP
#line 139 "H5LTanalyze.l"
-{
- if( is_str_size || (is_enum && is_enum_memb) ||
+{
+ if( is_str_size || (is_enum && is_enum_memb) ||
is_opq_size || (asindex>-1 && arr_stack[asindex].is_dim) ||
(csindex>-1 && cmpd_stack[csindex].is_field) ) {
H5LTyylval.ival = atoi(yytext);
- return NUMBER;
+ return NUMBER;
} else
REJECT;
}
@@ -1378,7 +1387,7 @@ YY_RULE_SETUP
#line 149 "H5LTanalyze.l"
{
/*if it's first quote, and is a compound field name or an enum symbol*/
- if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field))
+ if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field))
&& first_quote) {
first_quote = 0;
BEGIN TAG_STRING;
@@ -1441,7 +1450,7 @@ YY_RULE_SETUP
#line 174 "H5LTanalyze.l"
ECHO;
YY_BREAK
-#line 1423 "H5LTanalyze.c"
+#line 1432 "H5LTanalyze.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TAG_STRING):
yyterminate();
@@ -2323,8 +2332,8 @@ int main()
int my_yyinput(char *buf, int max_size)
{
int ret;
-
- memcpy(buf, myinput, input_len);
+
+ memcpy(buf, myinput, input_len);
ret = input_len;
return ret;
}
@@ -2332,6 +2341,7 @@ int my_yyinput(char *buf, int max_size)
int H5LTyyerror(char *msg)
{
printf("ERROR: %s before \"%s\".\n", msg, yytext);
+ return 0;
}
int yywrap()
diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l
index dbba15a..3f63f50 100644
--- a/hl/src/H5LTanalyze.l
+++ b/hl/src/H5LTanalyze.l
@@ -184,6 +184,7 @@ int my_yyinput(char *buf, int max_size)
int H5LTyyerror(char *msg)
{
printf("ERROR: %s before \"%s\".\n", msg, yytext);
+ return 0;
}
int yywrap()
diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c
index 8a77f13..0b6305b 100644
--- a/hl/src/H5TB.c
+++ b/hl/src/H5TB.c
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <string.h>
+#include "H5private.h"
#include "H5LTprivate.h"
#include "H5TBprivate.h"
@@ -663,7 +664,7 @@ herr_t H5TBwrite_fields_index( hid_t loc_id,
hid_t m_sid=-1;
hid_t file_space_id=-1;
char *member_name;
- hsize_t i, j;
+ hsize_t i;
hid_t preserve_id;
size_t size_native;
@@ -688,14 +689,19 @@ herr_t H5TBwrite_fields_index( hid_t loc_id,
/* iterate tru the members */
for ( i = 0; i < nfields; i++)
{
+ unsigned j;
+
+ /* Range check value */
+ if(field_index[i] < 0)
+ goto out;
- j = field_index[i];
+ j = (unsigned)field_index[i];
/* get the member name */
- member_name = H5Tget_member_name( tid, (unsigned) j );
+ member_name = H5Tget_member_name( tid, j );
/* get the member type */
- if (( member_type_id = H5Tget_member_type( tid, (unsigned) j )) < 0)
+ if (( member_type_id = H5Tget_member_type( tid, j )) < 0)
goto out;
/* convert to native type */
@@ -1149,7 +1155,7 @@ herr_t H5TBread_fields_index( hid_t loc_id,
hid_t m_sid=-1;
hsize_t mem_size[1];
size_t size_native;
- hsize_t i, j;
+ hsize_t i;
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
@@ -1166,13 +1172,19 @@ herr_t H5TBread_fields_index( hid_t loc_id,
/* iterate tru the members */
for ( i = 0; i < nfields; i++)
{
- j = field_index[i];
+ unsigned j;
+
+ /* Range check */
+ if(field_index[i] < 0)
+ goto out;
+
+ j = (unsigned)field_index[i];
/* get the member name */
- member_name = H5Tget_member_name( tid, (unsigned) j );
+ member_name = H5Tget_member_name( tid, j );
/* get the member type */
- if (( member_type_id = H5Tget_member_type( tid, (unsigned) j )) < 0)
+ if (( member_type_id = H5Tget_member_type( tid, j )) < 0)
goto out;
/* get the member size */
@@ -1289,7 +1301,6 @@ herr_t H5TBdelete_record( hid_t loc_id,
hsize_t start,
hsize_t nrecords )
{
-
hsize_t nfields;
hsize_t ntotal_records;
hsize_t read_start;
@@ -1304,8 +1315,8 @@ herr_t H5TBdelete_record( hid_t loc_id,
hsize_t mem_size[1];
unsigned char *tmp_buf=NULL;
size_t src_size;
- size_t *src_offset;
- size_t *src_sizes;
+ size_t *src_offset = NULL;
+ size_t *src_sizes = NULL;
hsize_t dims[1];
/*-------------------------------------------------------------------------
@@ -1315,23 +1326,20 @@ herr_t H5TBdelete_record( hid_t loc_id,
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &ntotal_records ) < 0)
- return -1;
-
- src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t));
- src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t));
+ goto out;
- if (src_offset == NULL )
- return -1;
- if (src_sizes == NULL )
- return -1;
+ if(NULL == (src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t))))
+ goto out;
+ if(NULL == (src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t))))
+ goto out;
/* get field info */
if (H5TBget_field_info( loc_id, dset_name, NULL, src_sizes, src_offset, &src_size ) < 0)
- return -1;
+ goto out;
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
- return -1;
+ goto out;
/*-------------------------------------------------------------------------
* read the records after the deleted one(s)
@@ -1343,14 +1351,12 @@ herr_t H5TBdelete_record( hid_t loc_id,
if ( read_nrecords )
{
- tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, src_size );
-
- if (tmp_buf == NULL )
- return -1;
+ if(NULL == (tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, src_size )))
+ goto out;
/* read the records after the deleted one(s) */
if (H5TBread_records( loc_id, dset_name, read_start, read_nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0)
- return -1;
+ goto out;
/*-------------------------------------------------------------------------
* write the records in another position
@@ -1406,31 +1412,34 @@ herr_t H5TBdelete_record( hid_t loc_id,
/* close dataset */
if (H5Dclose( did ) < 0)
- return -1;
-
- if (tmp_buf !=NULL)
- free( tmp_buf );
- free( src_offset );
- free( src_sizes );
+ goto out;
+ if(tmp_buf)
+ free(tmp_buf);
+ if(src_offset)
+ free(src_offset);
+ if(src_sizes)
+ free(src_sizes);
return 0;
/* error zone */
out:
-
- if (tmp_buf !=NULL )
- free( tmp_buf );
+ if(tmp_buf)
+ free(tmp_buf);
+ if(src_offset)
+ free(src_offset);
+ if(src_sizes)
+ free(src_sizes);
H5E_BEGIN_TRY
{
H5Tclose(mem_type_id);
H5Dclose(did);
H5Tclose(tid);
H5Sclose(sid);
+ H5Sclose(m_sid);
} H5E_END_TRY;
return -1;
-
-
}
/*-------------------------------------------------------------------------
@@ -1629,10 +1638,10 @@ herr_t H5TBadd_records_from( hid_t loc_id,
hsize_t mem_size[1];
hsize_t nfields;
hsize_t ntotal_records;
- unsigned char *tmp_buf;
+ unsigned char *tmp_buf = NULL;
size_t src_size;
- size_t *src_offset;
- size_t *src_sizes;
+ size_t *src_offset = NULL;
+ size_t *src_sizes = NULL;
/*-------------------------------------------------------------------------
* first we get information about type size and offsets on disk
@@ -1641,17 +1650,16 @@ herr_t H5TBadd_records_from( hid_t loc_id,
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name1, &nfields, &ntotal_records ) < 0)
- return -1;
-
- src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t));
- src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t));
+ goto out;
- if (src_offset == NULL )
- return -1;
+ if(NULL == (src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t))))
+ goto out;
+ if(NULL == (src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t))))
+ goto out;
/* get field info */
if (H5TBget_field_info( loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size ) < 0)
- return -1;
+ goto out;
/*-------------------------------------------------------------------------
* Get information about the first table and read it
@@ -1660,7 +1668,7 @@ herr_t H5TBadd_records_from( hid_t loc_id,
/* open the 1st dataset. */
if ((did_1 = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0)
- return -1;
+ goto out;
/* get the datatype */
if ((tid_1 = H5Dget_type( did_1 )) < 0)
@@ -1674,7 +1682,8 @@ herr_t H5TBadd_records_from( hid_t loc_id,
if (( type_size1 = H5Tget_size( tid_1 )) == 0 )
goto out;
- tmp_buf = (unsigned char *)calloc((size_t)nrecords, type_size1 );
+ if(NULL == (tmp_buf = (unsigned char *)calloc((size_t)nrecords, type_size1 )))
+ goto out;
/* define a hyperslab in the dataset of the size of the records */
offset[0] = start1;
@@ -1707,18 +1716,27 @@ herr_t H5TBadd_records_from( hid_t loc_id,
if (H5Sclose( sid_1 ) < 0)
goto out;
if (H5Tclose( tid_1 ) < 0)
- return -1;
+ goto out;
if (H5Dclose( did_1 ) < 0)
- return -1;
+ goto out;
- free( tmp_buf );
- free( src_offset );
- free( src_sizes );
+ if(tmp_buf)
+ free(tmp_buf);
+ if(src_offset)
+ free(src_offset);
+ if(src_sizes)
+ free(src_sizes);
return 0;
/* error zone */
out:
+ if(tmp_buf)
+ free(tmp_buf);
+ if(src_offset)
+ free(src_offset);
+ if(src_sizes)
+ free(src_sizes);
H5E_BEGIN_TRY
{
H5Dclose(did_1);
@@ -1748,50 +1766,50 @@ out:
*
*-------------------------------------------------------------------------
*/
-herr_t H5TBcombine_tables( hid_t loc_id1,
+herr_t H5TBcombine_tables(hid_t loc_id1,
const char *dset_name1,
hid_t loc_id2,
const char *dset_name2,
- const char *dset_name3 )
+ const char *dset_name3)
{
-
/* identifiers for the 1st dataset. */
- hid_t did_1=-1;
- hid_t tid_1=-1;
- hid_t sid_1=-1;
- hid_t pid_1=-1;
+ hid_t did_1 = H5I_BADID;
+ hid_t tid_1 = H5I_BADID;
+ hid_t sid_1 = H5I_BADID;
+ hid_t pid_1 = H5I_BADID;
/* identifiers for the 2nd dataset. */
- hid_t did_2=-1;
- hid_t tid_2=-1;
- hid_t sid_2=-1;
- hid_t pid_2=-1;
+ hid_t did_2 = H5I_BADID;
+ hid_t tid_2 = H5I_BADID;
+ hid_t sid_2 = H5I_BADID;
+ hid_t pid_2 = H5I_BADID;
/* identifiers for the 3rd dataset. */
- hid_t did_3=-1;
- hid_t tid_3=-1;
- hid_t sid_3=-1;
- hid_t pid_3=-1;
+ hid_t did_3 = H5I_BADID;
+ hid_t tid_3 = H5I_BADID;
+ hid_t sid_3 = H5I_BADID;
+ hid_t pid_3 = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hid_t member_type_id = H5I_BADID;
+ hid_t attr_id = H5I_BADID;
hsize_t count[1];
hsize_t offset[1];
- hid_t m_sid;
hsize_t mem_size[1];
hsize_t nfields;
hsize_t nrecords;
hsize_t dims[1];
- hsize_t maxdims[1] = { H5S_UNLIMITED };
+ hsize_t maxdims[1] = {H5S_UNLIMITED};
+ hsize_t i;
size_t type_size;
- hid_t sid;
- hid_t member_type_id;
size_t member_offset;
+ size_t src_size;
+ size_t *src_offset = NULL;
+ size_t *src_sizes = NULL;
char attr_name[255];
- hid_t attr_id;
char aux[255];
- unsigned char *tmp_buf;
- unsigned char *tmp_fill_buf;
- hsize_t i;
- size_t src_size;
- size_t *src_offset;
- size_t *src_sizes;
- int has_fill=0;
+ unsigned char *tmp_buf = NULL;
+ unsigned char *tmp_fill_buf = NULL;
+ htri_t has_fill;
+ int ret_val = -1;
/*-------------------------------------------------------------------------
* first we get information about type size and offsets on disk
@@ -1799,18 +1817,17 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
*/
/* get the number of records and fields */
- if (H5TBget_table_info ( loc_id1, dset_name1, &nfields, &nrecords ) < 0)
- return -1;
-
- src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t));
- src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t));
+ if(H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0)
+ goto out;
- if (src_offset == NULL )
- return -1;
+ if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ goto out;
+ if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ goto out;
/* get field info */
- if (H5TBget_field_info( loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size ) < 0)
- return -1;
+ if(H5TBget_field_info(loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* get information about the first table
@@ -1818,24 +1835,24 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
*/
/* open the 1st dataset. */
- if ((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0)
+ if((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if ((tid_1 = H5Dget_type( did_1 )) < 0)
+ if((tid_1 = H5Dget_type(did_1)) < 0)
goto out;
/* get the dataspace handle */
- if ((sid_1 = H5Dget_space( did_1 )) < 0)
+ if((sid_1 = H5Dget_space(did_1)) < 0)
goto out;
/* get creation properties list */
- if ((pid_1 = H5Dget_create_plist( did_1 )) < 0)
+ if((pid_1 = H5Dget_create_plist(did_1)) < 0)
goto out;
/* get the dimensions */
- if (H5TBget_table_info ( loc_id1, dset_name1, &nfields, &nrecords ) < 0)
- return -1;
+ if(H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* make the merged table with no data originally
@@ -1843,11 +1860,11 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
*/
/* clone the property list */
- if ((pid_3 = H5Pcopy(pid_1)) < 0)
+ if((pid_3 = H5Pcopy(pid_1)) < 0)
goto out;
/* clone the type id */
- if ((tid_3 = H5Tcopy(tid_1)) < 0)
+ if((tid_3 = H5Tcopy(tid_1)) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -1858,96 +1875,97 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
dims[0] = 0;
/* create a simple data space with unlimited size */
- if ((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0)
- return -1;
+ if((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0)
+ goto out;
/* create the dataset */
- if ((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0)
+ if((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
* attach the conforming table attributes
*-------------------------------------------------------------------------
*/
- if (H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0)
+ if(H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0)
goto out;
/*-------------------------------------------------------------------------
* get attributes
*-------------------------------------------------------------------------
*/
-
type_size = H5Tget_size(tid_3);
/* alloc fill value attribute buffer */
- tmp_fill_buf = (unsigned char *)malloc(type_size);
+ if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(type_size)))
+ goto out;
/* get the fill value attributes */
- has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf);
+ if((has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf)) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* attach the fill attributes from previous table
*-------------------------------------------------------------------------
*/
- if (has_fill == 1 )
- {
+ if(has_fill) {
- if (( sid = H5Screate(H5S_SCALAR)) < 0)
+ if((sid = H5Screate(H5S_SCALAR)) < 0)
goto out;
- for ( i = 0; i < nfields; i++)
- {
-
+ for(i = 0; i < nfields; i++) {
/* get the member type */
- if (( member_type_id = H5Tget_member_type( tid_3, (unsigned) i )) < 0)
+ if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0)
goto out;
/* get the member offset */
member_offset = H5Tget_member_offset(tid_3, (unsigned)i);
- strcpy(attr_name, "FIELD_");
- sprintf(aux, "%d", (int)i);
- strcat(attr_name, aux);
- sprintf(aux, "%s", "_FILL");
- strcat(attr_name, aux);
+ HDstrncpy(attr_name, "FIELD_", 6);
+ HDsnprintf(aux, 12, "%d", (int)i);
+ HDstrncat(attr_name, aux, 12);
+ HDsnprintf(aux, 6, "%s", "_FILL");
+ HDstrncat(attr_name, aux, 7);
- if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- if (H5Awrite(attr_id, member_type_id, tmp_fill_buf+member_offset) < 0)
+ if(H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0)
goto out;
- if (H5Aclose(attr_id) < 0)
+ if(H5Aclose(attr_id) < 0)
goto out;
+ attr_id = H5I_BADID;
- if (H5Tclose(member_type_id) < 0)
+ if(H5Tclose(member_type_id) < 0)
goto out;
+ member_type_id = H5I_BADID;
}
/* close data space. */
- if (H5Sclose( sid ) < 0)
+ if(H5Sclose(sid) < 0)
goto out;
+ sid = H5I_BADID;
}
/*-------------------------------------------------------------------------
* read data from 1st table
*-------------------------------------------------------------------------
*/
-
- tmp_buf = (unsigned char *)calloc((size_t) nrecords, type_size );
+ if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size)))
+ goto out;
/* define a hyperslab in the dataset of the size of the records */
offset[0] = 0;
count[0] = nrecords;
- if (H5Sselect_hyperslab( sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
+ if(H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
/* create a memory dataspace handle */
mem_size[0] = count[0];
- if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
+ if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0)
goto out;
- if (H5Dread( did_1, tid_1, m_sid, sid_1, H5P_DEFAULT, tmp_buf ) < 0)
+ if(H5Dread(did_1, tid_1, m_sid, sid_1, H5P_DEFAULT, tmp_buf) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -1956,27 +1974,32 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
*/
/* append the records to the new table */
- if (H5TBappend_records( loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0)
+ if(H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0)
goto out;
/*-------------------------------------------------------------------------
* release resources from 1st table
*-------------------------------------------------------------------------
*/
-
- if (H5Sclose( m_sid ) < 0)
+ if(H5Sclose(m_sid) < 0)
goto out;
- if(H5Sclose( sid_1 ) < 0)
+ m_sid = H5I_BADID;
+ if(H5Sclose(sid_1) < 0)
goto out;
- if(H5Tclose( tid_1 ) < 0)
+ sid_1 = H5I_BADID;
+ if(H5Tclose(tid_1) < 0)
goto out;
- if(H5Pclose( pid_1 ) < 0)
+ tid_1 = H5I_BADID;
+ if(H5Pclose(pid_1) < 0)
goto out;
- if(H5Dclose( did_1 ) < 0)
+ pid_1 = H5I_BADID;
+ if(H5Dclose(did_1) < 0)
goto out;
+ did_1 = H5I_BADID;
/* Release resources. */
- free( tmp_buf );
+ free(tmp_buf);
+ tmp_buf = NULL;
/*-------------------------------------------------------------------------
* get information about the 2nd table
@@ -1984,44 +2007,45 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
*/
/* open the dataset. */
- if ((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0)
+ if((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if ((tid_2 = H5Dget_type( did_2 )) < 0)
+ if((tid_2 = H5Dget_type(did_2)) < 0)
goto out;
/* get the dataspace handle */
- if ((sid_2 = H5Dget_space( did_2 )) < 0)
+ if((sid_2 = H5Dget_space(did_2)) < 0)
goto out;
/* get the property list handle */
- if ((pid_2 = H5Dget_create_plist( did_2 )) < 0)
+ if((pid_2 = H5Dget_create_plist(did_2)) < 0)
goto out;
/* get the dimensions */
- if (H5TBget_table_info ( loc_id2, dset_name2, &nfields, &nrecords ) < 0)
- return -1;
+ if(H5TBget_table_info(loc_id2, dset_name2, &nfields, &nrecords) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* read data from 2nd table
*-------------------------------------------------------------------------
*/
- tmp_buf = (unsigned char *)calloc((size_t) nrecords, type_size );
+ if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size)))
+ goto out;
/* define a hyperslab in the dataset of the size of the records */
offset[0] = 0;
count[0] = nrecords;
- if (H5Sselect_hyperslab( sid_2, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
+ if(H5Sselect_hyperslab(sid_2, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
/* create a memory dataspace handle */
mem_size[0] = count[0];
- if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
+ if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0)
goto out;
- if (H5Dread( did_2, tid_2, m_sid, sid_2, H5P_DEFAULT, tmp_buf ) < 0)
+ if(H5Dread(did_2, tid_2, m_sid, sid_2, H5P_DEFAULT, tmp_buf) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2030,7 +2054,7 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
*/
/* append the records to the new table */
- if (H5TBappend_records( loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0)
+ if(H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2038,58 +2062,88 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
*-------------------------------------------------------------------------
*/
- if (H5Sclose( m_sid ) < 0)
+ if(H5Sclose(m_sid) < 0)
goto out;
- if (H5Sclose( sid_2 ) < 0)
+ m_sid = H5I_BADID;
+ if(H5Sclose(sid_2) < 0)
goto out;
- if (H5Tclose( tid_2 ) < 0)
- return -1;
- if (H5Pclose( pid_2 ) < 0)
+ sid_2 = H5I_BADID;
+ if(H5Tclose(tid_2) < 0)
goto out;
- if (H5Dclose( did_2 ) < 0)
- return -1;
+ tid_2 = H5I_BADID;
+ if(H5Pclose(pid_2) < 0)
+ goto out;
+ pid_2 = H5I_BADID;
+ if(H5Dclose(did_2) < 0)
+ goto out;
+ did_2 = H5I_BADID;
/*-------------------------------------------------------------------------
* release resources from 3rd table
*-------------------------------------------------------------------------
*/
- if (H5Sclose( sid_3 ) < 0)
- return -1;
- if (H5Tclose( tid_3 ) < 0)
- return -1;
- if (H5Pclose( pid_3 ) < 0)
- return -1;
- if (H5Dclose( did_3 ) < 0)
- return -1;
-
- /* Release resources. */
- free( tmp_buf );
- free( tmp_fill_buf );
- free( src_offset );
- free( src_sizes );
+ if(H5Sclose(sid_3) < 0)
+ goto out;
+ sid_3 = H5I_BADID;
+ if(H5Tclose(tid_3) < 0)
+ goto out;
+ tid_3 = H5I_BADID;
+ if(H5Pclose(pid_3) < 0)
+ goto out;
+ pid_3 = H5I_BADID;
+ if(H5Dclose(did_3) < 0)
+ goto out;
+ did_3 = H5I_BADID;
- return 0;
+ ret_val = 0;
- /* error zone */
out:
- H5E_BEGIN_TRY
- {
- H5Dclose(did_1);
- H5Sclose(sid_1);
- H5Tclose(tid_1);
- H5Pclose(pid_1);
- H5Dclose(did_2);
- H5Sclose(sid_2);
- H5Tclose(tid_2);
- H5Pclose(pid_2);
- H5Dclose(did_3);
- H5Sclose(sid_3);
- H5Tclose(tid_3);
- H5Pclose(pid_3);
+ if(tmp_buf)
+ free(tmp_buf);
+ if(tmp_fill_buf)
+ free(tmp_fill_buf);
+ if(src_offset)
+ free(src_offset);
+ if(src_sizes)
+ free(src_sizes);
+
+ H5E_BEGIN_TRY {
+ if(member_type_id > 0)
+ H5Tclose(member_type_id);
+ if(attr_id > 0)
+ H5Aclose(attr_id);
+ if(sid > 0)
+ H5Sclose(sid);
+ if(m_sid > 0)
+ H5Sclose(m_sid);
+ if(pid_1 > 0)
+ H5Pclose(pid_1);
+ if(tid_1 > 0)
+ H5Tclose(tid_1);
+ if(sid_1 > 0)
+ H5Sclose(sid_1);
+ if(did_1 > 0)
+ H5Dclose(did_1);
+ if(pid_2 > 0)
+ H5Pclose(pid_2);
+ if(tid_2 > 0)
+ H5Tclose(tid_2);
+ if(sid_2 > 0)
+ H5Sclose(sid_2);
+ if(did_2 > 0)
+ H5Dclose(did_2);
+ if(pid_3 > 0)
+ H5Pclose(pid_3);
+ if(tid_3 > 0)
+ H5Tclose(tid_3);
+ if(sid_3 > 0)
+ H5Sclose(sid_3);
+ if(did_3 > 0)
+ H5Dclose(did_3);
} H5E_END_TRY;
- return -1;
+ return ret_val;
}
/*-------------------------------------------------------------------------
@@ -2581,7 +2635,7 @@ herr_t H5TBdelete_field( hid_t loc_id,
size_t member_offset;
hid_t attr_id;
hsize_t i;
- int has_fill=0;
+ htri_t has_fill = 0;
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0)
@@ -3017,7 +3071,7 @@ herr_t H5TBAget_title( hid_t loc_id,
*
* Purpose: Read the table attribute fill values
*
-* Return: Success: 0, Failure: -1
+* Return: Success: TRUE/FALSE, Failure: -1
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -3029,12 +3083,10 @@ herr_t H5TBAget_title( hid_t loc_id,
*
*-------------------------------------------------------------------------
*/
-
-
-herr_t H5TBAget_fill( hid_t loc_id,
+htri_t H5TBAget_fill(hid_t loc_id,
const char *dset_name,
hid_t dset_id,
- unsigned char *dst_buf )
+ unsigned char *dst_buf)
{
hsize_t nfields;
@@ -3149,9 +3201,7 @@ herr_t H5TBget_table_info ( hid_t loc_id,
*/
if (nfields)
- {
- *nfields = num_members;
- }
+ *nfields = (hsize_t)num_members;
/*-------------------------------------------------------------------------
@@ -3331,19 +3381,19 @@ int H5TB_find_field( const char *field, const char *field_list )
const char *start = field_list;
const char *end;
- while ( (end = strstr( start, "," )) != 0 )
+ while ( (end = HDstrstr( start, "," )) != 0 )
{
- size_t count = end - start;
- if(strncmp(start, field, count) == 0 && count == strlen(field) )
+ ptrdiff_t count = end - start;
+
+ if(HDstrncmp(start, field, (size_t)count) == 0 && (size_t)count == HDstrlen(field) )
return 1;
start = end + 1;
}
- if(strcmp( start, field ) == 0 )
+ if(HDstrcmp( start, field ) == 0 )
return 1;
return -1;
-
}
diff --git a/hl/src/H5TBpublic.h b/hl/src/H5TBpublic.h
index 4dd17bb..874ef20 100644
--- a/hl/src/H5TBpublic.h
+++ b/hl/src/H5TBpublic.h
@@ -219,10 +219,10 @@ H5_HLDLL herr_t H5TBdelete_field( hid_t loc_id,
H5_HLDLL herr_t H5TBAget_title( hid_t loc_id,
char *table_title );
-H5_HLDLL herr_t H5TBAget_fill( hid_t loc_id,
+H5_HLDLL htri_t H5TBAget_fill(hid_t loc_id,
const char *dset_name,
hid_t dset_id,
- unsigned char *dst_buf );
+ unsigned char *dst_buf);
#ifdef __cplusplus
}
diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in
index 5da7bd2..ba9c2ad 100644
--- a/hl/src/Makefile.in
+++ b/hl/src/Makefile.in
@@ -457,7 +457,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog
# Add libtool shared library version numbers to the HDF5 library
# See libtool versioning documentation online.
LT_VERS_INTERFACE = 6
-LT_VERS_REVISION = 118
+LT_VERS_REVISION = 122
LT_VERS_AGE = 0
# This library is our main target.
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index 4cef1b4..a4a10e4 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -676,7 +676,7 @@ static int test_generate(void)
goto out;
/* Indicate success */
- retval = 0;
+ return 0;
/* error zone, gracefully close */
out:
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index 3fface8..a611088 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -2152,9 +2152,12 @@ int main( void )
/* test attribute functions */
nerrors += test_attr();
- /* test text-dtype functions */
+ /* test valid path functions */
nerrors += test_valid_path();
+ /* test text-dtype functions */
+ nerrors += test_text_dtype();
+
/* check for errors */
if (nerrors)
goto error;