summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hl/src/H5LT.c6
-rw-r--r--hl/src/H5LTanalyze.c8
-rw-r--r--hl/src/H5LTanalyze.l8
-rw-r--r--hl/src/H5LTparse.y2
-rw-r--r--hl/test/test_image.c7
-rw-r--r--src/H5Odbg.c14
-rw-r--r--src/H5Olink.c5
-rw-r--r--src/H5Zdeflate.c2
-rw-r--r--src/H5Zshuffle.c2
-rw-r--r--test/cache_api.c4
-rw-r--r--test/fillval.c16
-rw-r--r--test/freespace.c6
-rw-r--r--test/gen_cross.c18
-rw-r--r--test/istore.c2
-rw-r--r--test/tselect.c5
-rw-r--r--tools/h5repack/h5repack_refs.c199
16 files changed, 143 insertions, 161 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index 98f2ff2..96cd014 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -27,7 +27,7 @@
#define INCREMENT 1024
#define TMP_LEN 256
#define MAX(a,b) (((a)>(b)) ? (a) : (b))
-int input_len;
+size_t input_len;
char *myinput;
size_t indent = 0;
@@ -2291,9 +2291,9 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt)
size_t dst_size; /*destination value type size */
int i;
- if((nmembs = H5Tget_nmembers(type))==0)
+ if((nmembs = H5Tget_nmembers(type))<=0)
goto out;
- assert(nmembs>0);
+
if((super = H5Tget_super(type)) < 0)
goto out;
diff --git a/hl/src/H5LTanalyze.c b/hl/src/H5LTanalyze.c
index f02bed6..b25db7e 100644
--- a/hl/src/H5LTanalyze.c
+++ b/hl/src/H5LTanalyze.c
@@ -820,7 +820,7 @@ int my_yyinput(char *, int);
#define YY_BUF_SIZE 262144 /*Define read buffer to be 256K*/
extern char *myinput;
-extern int input_len;
+extern size_t input_len;
#define STACK_SIZE 16
@@ -855,10 +855,6 @@ extern hbool_t is_opq_tag;
hbool_t first_quote = 1;
-/* For Lex and Yacc */
-/*int input_len;
-char *myinput;*/
-
#define TAG_STRING 1
#line 843 "H5LTanalyze.c"
@@ -2342,7 +2338,7 @@ int my_yyinput(char *buf, int max_size)
int ret;
memcpy(buf, myinput, input_len);
- ret = input_len;
+ ret = (int)input_len;
return ret;
}
diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l
index 581672b..7407520 100644
--- a/hl/src/H5LTanalyze.l
+++ b/hl/src/H5LTanalyze.l
@@ -30,7 +30,7 @@ int my_yyinput(char *, int);
#define YY_BUF_SIZE 262144 /*Define read buffer to be 256K*/
extern char *myinput;
-extern int input_len;
+extern size_t input_len;
#define STACK_SIZE 16
@@ -65,10 +65,6 @@ extern hbool_t is_opq_tag;
hbool_t first_quote = 1;
-/* For Lex and Yacc */
-/*int input_len;
-char *myinput;*/
-
%}
%s TAG_STRING
@@ -181,7 +177,7 @@ int my_yyinput(char *buf, int max_size)
int ret;
memcpy(buf, myinput, input_len);
- ret = input_len;
+ ret = (int)input_len;
return ret;
}
diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y
index b91e97e..973f2cb 100644
--- a/hl/src/H5LTparse.y
+++ b/hl/src/H5LTparse.y
@@ -51,7 +51,7 @@ int asindex = -1; /*pointer to the top of array stack*/
hbool_t is_str_size = 0; /*flag to lexer for string size*/
hbool_t is_str_pad = 0; /*flag to lexer for string padding*/
-H5T_pad_t str_pad; /*variable for string padding*/
+H5T_str_t str_pad; /*variable for string padding*/
H5T_cset_t str_cset; /*variable for string character set*/
hbool_t is_variable = 0; /*variable for variable-length string*/
size_t str_size; /*variable for string size*/
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index d2d9cab..3109a36 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -544,7 +544,7 @@ static int test_generate(void)
int imax, jmax, kmax;
int n_elements;
float valex, xmin, xmax, value;
- FILE *f;
+ FILE *f = NULL;
char *srcdir = getenv("srcdir"); /* the source directory */
char data_file[512]=""; /* buffer to hold name of existing data file */
int i;
@@ -648,7 +648,8 @@ static int test_generate(void)
fscanf( f, "%f ", &value );
data[i] = value;
}
- HDfclose( f );
+ HDfclose(f);
+ f = NULL;
/*-------------------------------------------------------------------------
* transform the data from floating point to unsigned char
@@ -758,6 +759,8 @@ out:
H5E_BEGIN_TRY {
H5Fclose(fid);
} H5E_END_TRY;
+ if(f)
+ HDfclose(f);
H5_FAILED();
return retval;
}
diff --git a/src/H5Odbg.c b/src/H5Odbg.c
index 5901c61..b91a51a 100644
--- a/src/H5Odbg.c
+++ b/src/H5Odbg.c
@@ -455,30 +455,32 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i
hbool_t flag_printed = FALSE;
if(oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) {
- HDfprintf(stream, "%s%s", (flag_printed ? ", " : "<"), "S");
+ HDfprintf(stream, "<S");
flag_printed = TRUE;
} /* end if */
if(oh->mesg[i].flags & H5O_MSG_FLAG_CONSTANT) {
- HDfprintf(stream, "%s%s", (flag_printed ? ", " : "<"), "C");
+ HDfprintf(stream, "%sC", (flag_printed ? ", " : "<"));
flag_printed = TRUE;
} /* end if */
if(oh->mesg[i].flags & H5O_MSG_FLAG_DONTSHARE) {
- HDfprintf(stream, "%s%s", (flag_printed ? ", " : "<"), "DS");
+ HDfprintf(stream, "%sDS", (flag_printed ? ", " : "<"));
flag_printed = TRUE;
} /* end if */
if(oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN) {
- HDfprintf(stream, "%s%s", (flag_printed ? ", " : "<"), "FIU");
+ HDfprintf(stream, "%sFIU", (flag_printed ? ", " : "<"));
flag_printed = TRUE;
} /* end if */
if(oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) {
- HDfprintf(stream, "%s%s", (flag_printed ? ", " : "<"), "MIU");
+ HDfprintf(stream, "%sMIU", (flag_printed ? ", " : "<"));
flag_printed = TRUE;
} /* end if */
if(oh->mesg[i].flags & H5O_MSG_FLAG_WAS_UNKNOWN) {
HDassert(oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN);
- HDfprintf(stream, "%s%s", (flag_printed ? ", " : "<"), "WU");
+ HDfprintf(stream, "%sWU", (flag_printed ? ", " : "<"));
flag_printed = TRUE;
} /* end if */
+ if(!flag_printed)
+ HDfprintf(stream, "-");
HDfprintf(stream, ">\n");
if(oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS)
HDfprintf(stream, "%*s%-*s 0x%02x\n", indent + 3,"", MAX(0, fwidth - 3),
diff --git a/src/H5Olink.c b/src/H5Olink.c
index 4dda5fe..184f6b9 100644
--- a/src/H5Olink.c
+++ b/src/H5Olink.c
@@ -484,6 +484,9 @@ H5O_link_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Sanity check */
+ HDcompile_assert(sizeof(uint64_t) >= sizeof(size_t));
+
/* Get name's length */
name_len = (uint64_t)HDstrlen(lnk->name);
@@ -500,7 +503,7 @@ H5O_link_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
/* Set return value */
ret_value = 1 + /* Version */
1 + /* Link encoding flags */
- (lnk->type != H5L_TYPE_HARD ? 1 : 0) + /* Link type */
+ (lnk->type != H5L_TYPE_HARD ? (size_t)1 : 0) + /* Link type */
(lnk->corder_valid ? 8 : 0) + /* Creation order */
(lnk->cset != H5T_CSET_ASCII ? 1 : 0) + /* Character set */
name_size + /* Name length */
diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c
index f318c2f..82ad1ba 100644
--- a/src/H5Zdeflate.c
+++ b/src/H5Zdeflate.c
@@ -51,7 +51,7 @@ const H5Z_class2_t H5Z_DEFLATE[1] = {{
H5Z_filter_deflate, /* The actual filter function */
}};
-#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s))*1.001)+12)
+#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * (double)1.001f) + 12)
/*-------------------------------------------------------------------------
diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c
index 90509b0..4a67839 100644
--- a/src/H5Zshuffle.c
+++ b/src/H5Zshuffle.c
@@ -81,7 +81,7 @@ H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* Get datatype */
- if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE)))
+ if(NULL == (type = (const H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Get the filter's current parameters */
diff --git a/test/cache_api.c b/test/cache_api.c
index 85b2407..66f8143 100644
--- a/test/cache_api.c
+++ b/test/cache_api.c
@@ -883,7 +883,6 @@ mdc_api_call_smoke_check(int express_test)
hid_t properties;
char dset_name[64];
int i, j, k, l, m, n;
- int progress_counter;
herr_t status;
hsize_t dims[2];
hsize_t a_size[2];
@@ -1164,7 +1163,6 @@ mdc_api_call_smoke_check(int express_test)
/* initialize all datasets on a round robin basis */
i = 0;
- progress_counter = 0;
while ( ( pass ) && ( i < DSET_SIZE ) )
{
@@ -1249,7 +1247,6 @@ mdc_api_call_smoke_check(int express_test)
/* do random reads on all datasets */
n = 0;
- progress_counter = 0;
while ( ( pass ) && ( n < NUM_RANDOM_ACCESSES ) )
{
m = rand() % NUM_DSETS;
@@ -1376,7 +1373,6 @@ mdc_api_call_smoke_check(int express_test)
/* do random reads on data set 0 only */
m = 0;
n = 0;
- progress_counter = 0;
while ( ( pass ) && ( n < NUM_RANDOM_ACCESSES ) )
{
i = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE;
diff --git a/test/fillval.c b/test/fillval.c
index 16247b5..c2010ff 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -288,7 +288,7 @@ static int
test_getset_vl(hid_t fapl)
{
hsize_t dims[1] = {2};
- hid_t fileid = (-1), spaceid = (-1), typeid = (-1), datasetid = (-1), plistid = (-1);
+ hid_t fileid = (-1), spaceid = (-1), dtypeid = (-1), datasetid = (-1), plistid = (-1);
char fill_value[] = "aaaa";
char orig_fill_value[] = "aaaa";
char *f1 = fill_value;
@@ -298,18 +298,18 @@ test_getset_vl(hid_t fapl)
TESTING("property lists, with variable-length datatype");
/* Create string type. */
- if((typeid = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR
- if(H5Tset_size(typeid, H5T_VARIABLE) < 0) TEST_ERROR
+ if((dtypeid = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR
+ if(H5Tset_size(dtypeid, H5T_VARIABLE) < 0) TEST_ERROR
/* Set up dataset creation property list, with fill value */
if((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
- if(H5Pset_fill_value(plistid, typeid, &f1) < 0) TEST_ERROR
+ if(H5Pset_fill_value(plistid, dtypeid, &f1) < 0) TEST_ERROR
/* Modify original fill value string */
fill_value[0] = 'b';
/* Retrieve fill value from property */
- if(H5Pget_fill_value(plistid, typeid, &f2) < 0) TEST_ERROR
+ if(H5Pget_fill_value(plistid, dtypeid, &f2) < 0) TEST_ERROR
/* Verify that the fill value is the original value */
if(HDstrcmp(f2, orig_fill_value)) TEST_ERROR
@@ -323,7 +323,7 @@ test_getset_vl(hid_t fapl)
/* Write an dataset of this type. */
if((spaceid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR
- if((datasetid = H5Dcreate2(fileid, "Dataset", typeid, spaceid, H5P_DEFAULT, plistid, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((datasetid = H5Dcreate2(fileid, "Dataset", dtypeid, spaceid, H5P_DEFAULT, plistid, H5P_DEFAULT)) < 0) TEST_ERROR
/* Close IDs (except datatype) */
if(H5Dclose(datasetid) < 0) TEST_ERROR
@@ -340,7 +340,7 @@ test_getset_vl(hid_t fapl)
if((plistid = H5Dget_create_plist(datasetid)) < 0) TEST_ERROR
/* Query fill value */
- if(H5Pget_fill_value(plistid, typeid, &f2) < 0) TEST_ERROR
+ if(H5Pget_fill_value(plistid, dtypeid, &f2) < 0) TEST_ERROR
/* Verify that the fill value is the original value */
if(HDstrcmp(f2, orig_fill_value)) TEST_ERROR
@@ -352,7 +352,7 @@ test_getset_vl(hid_t fapl)
if(H5Dclose(datasetid) < 0) TEST_ERROR
if(H5Fclose(fileid) < 0) TEST_ERROR
if(H5Pclose(plistid) < 0) TEST_ERROR
- if(H5Tclose(typeid) < 0) TEST_ERROR
+ if(H5Tclose(dtypeid) < 0) TEST_ERROR
PASSED();
return 0;
diff --git a/test/freespace.c b/test/freespace.c
index 14b0f9a..9ab0d75 100644
--- a/test/freespace.c
+++ b/test/freespace.c
@@ -191,7 +191,7 @@ typedef struct {
hsize_t tot_sect_count;
} TEST_iter_ud_t;
-static herr_t TEST_sects_cb(const H5FS_section_info_t *_sect, void *_udata);
+static herr_t TEST_sects_cb(H5FS_section_info_t *_sect, void *_udata);
/*
@@ -340,9 +340,9 @@ error:
* iteration callback
*/
static herr_t
-TEST_sects_cb(const H5FS_section_info_t *_sect, void *_udata)
+TEST_sects_cb(H5FS_section_info_t *_sect, void *_udata)
{
- const TEST_free_section_t *sect = (const TEST_free_section_t *)_sect;
+ TEST_free_section_t *sect = (TEST_free_section_t *)_sect;
TEST_iter_ud_t *udata = (TEST_iter_ud_t *)_udata;
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/test/gen_cross.c b/test/gen_cross.c
index bdc2835..3b0a56f 100644
--- a/test/gen_cross.c
+++ b/test/gen_cross.c
@@ -24,6 +24,7 @@
* under hdf5/test/ directory.
*/
+#include <stdio.h>
#include "h5test.h"
#define H5FILE_NAME "data.h5"
@@ -70,7 +71,9 @@ int create_scale_offset_dsets_int(hid_t fid, hid_t fsid, hid_t msid);
int create_scale_offset_dsets_long_long(hid_t fid, hid_t fsid, hid_t msid);
int create_fletcher_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
int create_deflate_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
+#ifdef H5_HAVE_FILTER_SZIP
int create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
+#endif /* H5_HAVE_FILTER_SZIP */
int create_shuffle_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
int create_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
@@ -1016,6 +1019,7 @@ error:
#endif /* H5_HAVE_FILTER_DEFLATE */
}
+#ifdef H5_HAVE_FILTER_SZIP
/*-------------------------------------------------------------------------
* Function: create_szip_dsets_float
@@ -1035,7 +1039,6 @@ error:
int
create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid)
{
-#ifdef H5_HAVE_FILTER_SZIP
hid_t dataset; /* dataset handles */
hid_t dcpl;
float data[NX][NY]; /* data to write */
@@ -1097,15 +1100,8 @@ create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid)
if(H5Pclose(dcpl) < 0)
TEST_ERROR
-#else /* H5_HAVE_FILTER_SZIP */
- const char *not_supported= "Szip filter is not enabled. Can't create the dataset.";
-
- puts(not_supported);
-#endif /* H5_HAVE_FILTER_SZIP */
-
return 0;
-#ifdef H5_HAVE_FILTER_SZIP
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -1113,8 +1109,8 @@ error:
} H5E_END_TRY;
return -1;
-#endif /* H5_HAVE_FILTER_SZIP */
}
+#endif /* H5_HAVE_FILTER_SZIP */
/*-------------------------------------------------------------------------
@@ -1426,9 +1422,13 @@ main (void)
if(create_deflate_dsets_float(file, filespace, memspace) < 0)
{H5_FAILED(); AT(); return 1;}
+#ifdef H5_HAVE_FILTER_SZIP
/* Create a dataset of FLOAT with szip filter */
if(create_szip_dsets_float(file, filespace, memspace) < 0)
{H5_FAILED(); AT(); return 1;}
+#else /* H5_HAVE_FILTER_SZIP */
+ puts("Szip filter is not enabled. Can't create the dataset.");
+#endif /* H5_HAVE_FILTER_SZIP */
/* Create a dataset of FLOAT with shuffle filter */
if(create_shuffle_dsets_float(file, filespace, memspace) < 0)
diff --git a/test/istore.c b/test/istore.c
index 217dfc4..d088fe8 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -318,7 +318,7 @@ test_extend(hid_t f, const char *prefix,
nelmts = 1;
} else {
for (i=0, nelmts=1; i<(size_t)ndims; i++) {
- if (ctr % ndims == i) {
+ if (ctr % (size_t)ndims == i) {
offset[i] = max_corner[i];
size[i] = MIN(1, whole_size[i] - offset[i]);
} else {
diff --git a/test/tselect.c b/test/tselect.c
index 973a63f..eff9325 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -2734,7 +2734,6 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_
hid_t dset_type, hid_t xfer_plist)
{
hbool_t data_ok;
- hbool_t start_in_checker[5];
hid_t fapl; /* File access property list */
hid_t fid; /* HDF5 File IDs */
hid_t full_small_cube_sid; /* Dataspace for small cube w/all selection */
@@ -2955,7 +2954,6 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_
* large cube.
*/
- start_in_checker[0] = TRUE;
u = 0;
do {
if(small_rank_offset > 0)
@@ -3063,7 +3061,6 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_
sel_start);
- start_in_checker[0] = TRUE;
u = 0;
do {
if(0 < small_rank_offset)
@@ -3207,7 +3204,6 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_
small_rank,
sel_start);
- start_in_checker[0] = TRUE;
u = 0;
do {
if(small_rank_offset > 0)
@@ -3340,7 +3336,6 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_
small_rank,
sel_start);
- start_in_checker[0] = TRUE;
u = 0;
do {
if(small_rank_offset > 0)
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index 71615f2..b844280 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -193,8 +193,6 @@ int do_copy_refobjs(hid_t fidin,
goto error;
if(options->verbose)
{
-
-
printf(FORMAT_OBJ,"dset",travt->objs[i].name );
printf("object <%s> object reference created to <%s>\n",
travt->objs[i].name,
@@ -468,7 +466,7 @@ static int copy_refs_attr(hid_t loc_in,
hbool_t is_ref=0, is_ref_vlen=0, is_ref_array=0, is_ref_comp=0;
void *refbuf = NULL;
void *buf = NULL;
- const char* refname;
+ const char* refname = NULL;
int *ref_comp_index = NULL;
size_t *ref_comp_size = NULL;
int ref_comp_field_n = 0;
@@ -477,8 +475,7 @@ static int copy_refs_attr(hid_t loc_in,
if(H5Oget_info(loc_in, &oinfo) < 0)
goto error;
- for(u = 0; u < (unsigned)oinfo.num_attrs; u++)
- {
+ for(u = 0; u < (unsigned)oinfo.num_attrs; u++) {
is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0;
/* open attribute */
@@ -499,56 +496,55 @@ static int copy_refs_attr(hid_t loc_in,
is_ref = (type_class == H5T_REFERENCE);
- if (type_class == H5T_VLEN ) {
- hid_t base_type = -1;
- base_type = H5Tget_super(ftype_id);
- is_ref_vlen = (H5Tget_class(base_type)==H5T_REFERENCE);
- msize = H5Tget_size(base_type);
- H5Tclose(base_type);
+ if(type_class == H5T_VLEN ) {
+ hid_t base_type;
+
+ base_type = H5Tget_super(ftype_id);
+ is_ref_vlen = (H5Tget_class(base_type)==H5T_REFERENCE);
+ msize = H5Tget_size(base_type);
+ H5Tclose(base_type);
}
+ else if(type_class == H5T_ARRAY ) {
+ hid_t base_type;
- if (type_class == H5T_ARRAY ) {
- hid_t base_type = -1;
- base_type = H5Tget_super(ftype_id);
- is_ref_array = (H5Tget_class(base_type)==H5T_REFERENCE);
- msize = H5Tget_size(base_type);
- H5Tclose(base_type);
+ base_type = H5Tget_super(ftype_id);
+ is_ref_array = (H5Tget_class(base_type)==H5T_REFERENCE);
+ msize = H5Tget_size(base_type);
+ H5Tclose(base_type);
}
+ else if(type_class == H5T_COMPOUND) {
+ int nmembers = H5Tget_nmembers(ftype_id) ;
- if (type_class == H5T_COMPOUND) {
- int nmembers = H5Tget_nmembers(ftype_id) ;
- if (nmembers < 1)
- goto error;
+ if (nmembers < 1)
+ goto error;
ref_comp_index = (int *)HDmalloc(nmembers*sizeof (int));
ref_comp_size = (size_t *)HDmalloc(nmembers*sizeof(ref_comp_size));
ref_comp_field_n = 0;
- for (i=0; i<(unsigned)nmembers; i++) {
- hid_t mtid = H5Tget_member_type( ftype_id, i );
- if ((H5Tget_class(mtid)==H5T_REFERENCE)) {
- ref_comp_index[ref_comp_field_n] = i;
- ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid);
- ref_comp_field_n++;
- }
- H5Tclose(mtid);
- }
+ for (i=0; i<(unsigned)nmembers; i++) {
+ hid_t mtid = H5Tget_member_type( ftype_id, i );
+
+ if ((H5Tget_class(mtid)==H5T_REFERENCE)) {
+ ref_comp_index[ref_comp_field_n] = i;
+ ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid);
+ ref_comp_field_n++;
+ }
+ H5Tclose(mtid);
+ }
/* if compound don't contain reference type member, free the above
* mallocs. Otherwise there can be memory leaks by the 'continue'
* statement below. */
- if (!ref_comp_field_n)
- {
- if (ref_comp_index)
- {
- HDfree(ref_comp_index);
- ref_comp_index = NULL;
+ if (!ref_comp_field_n) {
+ if (ref_comp_index) {
+ HDfree(ref_comp_index);
+ ref_comp_index = NULL;
}
- if (ref_comp_size)
- {
+ if (ref_comp_size) {
HDfree(ref_comp_size);
- ref_comp_size = NULL;
+ ref_comp_size = NULL;
}
}
}
@@ -556,10 +552,10 @@ static int copy_refs_attr(hid_t loc_in,
is_ref_comp = (ref_comp_field_n > 0);
if (!(is_ref || is_ref_vlen || is_ref_array || is_ref_comp)) {
- H5Tclose(mtype_id);
- H5Tclose(ftype_id);
- H5Aclose(attr_id);
- continue;
+ H5Tclose(mtype_id);
+ H5Tclose(ftype_id);
+ H5Aclose(attr_id);
+ continue;
}
/* get name */
@@ -584,32 +580,30 @@ static int copy_refs_attr(hid_t loc_in,
nelmts *= dims[j];
if (is_ref_array) {
- unsigned array_rank = 0;
- hsize_t array_size = 1;
- hsize_t array_dims[H5S_MAX_RANK];
- hid_t base_type = -1;
- base_type = H5Tget_super(ftype_id);
- msize = H5Tget_size(base_type);
- H5Tclose(base_type);
-
- array_rank = H5Tget_array_ndims(mtype_id);
- H5Tget_array_dims2(mtype_id, array_dims);
+ unsigned array_rank = 0;
+ hsize_t array_size = 1;
+ hsize_t array_dims[H5S_MAX_RANK];
+ hid_t base_type;
+
+ base_type = H5Tget_super(ftype_id);
+ msize = H5Tget_size(base_type);
+ H5Tclose(base_type);
+
+ array_rank = H5Tget_array_ndims(mtype_id);
+ H5Tget_array_dims2(mtype_id, array_dims);
for(j = 0; j <array_rank; j++)
array_size *= array_dims[j];
nelmts *= array_size;
- }
+ }
if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
- if (nelmts>0)
- {
+ if (nelmts>0) {
/* handle object references */
- if((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE==msize))
- {
+ if((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE==msize)) {
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
- if(buf == NULL)
- {
+ if(buf == NULL) {
printf("cannot read into memory\n");
goto error;
} /* end if */
@@ -617,26 +611,23 @@ static int copy_refs_attr(hid_t loc_in,
goto error;
refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize);
- if(refbuf == NULL)
- {
- printf( "cannot allocate memory\n" );
+ if(refbuf == NULL) {
+ printf("cannot allocate memory\n");
goto error;
} /* end if */
- for(i = 0; i < (unsigned)nelmts; i++)
- {
+ for(i = 0; i < (unsigned)nelmts; i++) {
if (update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout, &((hobj_ref_t *)refbuf)[i], travt)<0)
- continue;
+ continue;
if(options->verbose)
printf("object <%s> reference created to <%s>\n", name, refname);
- } /* k */
- }/*H5T_STD_REF_OBJ*/
+ } /* i */
+ } /* H5T_STD_REF_OBJ */
/* handle region references */
- else if((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize))
- {
+ else if((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) {
buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize));
- if(buf == NULL)
- {
+
+ if(buf == NULL) {
printf( "cannot read into memory\n" );
goto error;
} /* end if */
@@ -648,16 +639,14 @@ static int copy_refs_attr(hid_t loc_in,
*-------------------------------------------------------------------------
*/
refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
- if(refbuf == NULL)
- {
+ if(refbuf == NULL) {
printf( "cannot allocate memory\n" );
goto error;
} /* end if */
- for(i = 0; i < (unsigned)nelmts; i++)
- {
+ for(i = 0; i < (unsigned)nelmts; i++) {
if (update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout, &((hdset_reg_ref_t *)refbuf)[i], travt)<0)
- continue;
+ continue;
if(options->verbose)
printf("object <%s> region reference created to <%s>\n", name, refname);
}
@@ -668,8 +657,7 @@ static int copy_refs_attr(hid_t loc_in,
buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t)));
refbuf = buf; /* reuse the read buffer for write */
- if(buf == NULL)
- {
+ if(buf == NULL) {
printf( "cannot read into memory\n" );
goto error;
} /* end if */
@@ -677,28 +665,31 @@ static int copy_refs_attr(hid_t loc_in,
if(H5Aread(attr_id, mtype_id, buf) < 0)
goto error;
- if (H5R_OBJ_REF_BUF_SIZE==msize) {
- hobj_ref_t ref_out;
- for (i=0; i<(unsigned)nelmts; i++) {
- hobj_ref_t *ptr = (hobj_ref_t *)((hvl_t *)buf)[i].p;
- for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
- if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt)<0)
- continue;
- HDmemcpy(&(ptr[j]), &ref_out, msize);
- }
- } /* for (i=0; i<nelems; i++) */
- } else if (H5R_DSET_REG_REF_BUF_SIZE == msize) {
-
- hdset_reg_ref_t ref_out;
- for (i=0; i<(unsigned)nelmts; i++) {
- hdset_reg_ref_t *ptr = (hdset_reg_ref_t *)((hvl_t *)buf)[i].p;
- for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
- if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out, travt)<0)
- continue;
- HDmemcpy(&(ptr[j]), &ref_out, msize);
- }
- } /* for (i=0; i<nelems; i++) */
- }
+ if (H5R_OBJ_REF_BUF_SIZE==msize) {
+ hobj_ref_t ref_out;
+
+ for (i=0; i<(unsigned)nelmts; i++) {
+ hobj_ref_t *ptr = (hobj_ref_t *)((hvl_t *)buf)[i].p;
+
+ for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
+ if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt)<0)
+ continue;
+ HDmemcpy(&(ptr[j]), &ref_out, msize);
+ }
+ } /* for (i=0; i<nelems; i++) */
+ } else if (H5R_DSET_REG_REF_BUF_SIZE == msize) {
+ hdset_reg_ref_t ref_out;
+
+ for (i=0; i<(unsigned)nelmts; i++) {
+ hdset_reg_ref_t *ptr = (hdset_reg_ref_t *)((hvl_t *)buf)[i].p;
+
+ for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
+ if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out, travt)<0)
+ continue;
+ HDmemcpy(&(ptr[j]), &ref_out, msize);
+ }
+ } /* for (i=0; i<nelems; i++) */
+ }
} /* else if (is_ref_vlen) */
else if (is_ref_comp) {
/* handle ref fields in a compound */
@@ -822,9 +813,9 @@ MapIdToName(hid_t refobj_id, trav_table_t *travt)
/* linear search */
for(u = 0; u < travt->nobjs; u++) {
- if(travt->objs[u].type == H5O_TYPE_DATASET ||
- travt->objs[u].type == H5O_TYPE_GROUP ||
- travt->objs[u].type == H5O_TYPE_NAMED_DATATYPE) {
+ if(travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET ||
+ travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP ||
+ travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) {
H5O_info_t ref_oinfo; /* Stat for the refobj id */
/* obtain information to identify the referenced object uniquely */