diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2016-07-22 22:43:18 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2016-07-22 22:43:18 (GMT) |
commit | 4af66b09e03af4e9b0b6a1293dfe746f48106aba (patch) | |
tree | 0cb162e0921a0a774a433f9d3cd9f08c44bbe57d /tools/h5repack | |
parent | 9b597a48552f5201b37793a4c6fece4fd9f1c346 (diff) | |
download | hdf5-4af66b09e03af4e9b0b6a1293dfe746f48106aba.zip hdf5-4af66b09e03af4e9b0b6a1293dfe746f48106aba.tar.gz hdf5-4af66b09e03af4e9b0b6a1293dfe746f48106aba.tar.bz2 |
[svn-r30219] Description:
More warning cleaups: down to 770 warnings (from ~940) in 134 files (from
148), with 28 unique kinds of warnings (from 31).
Tested on:
MacOSX/64 10.11.5 (amazon) w/serial & parallel
(h5committest forthcoming)
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack.c | 509 | ||||
-rw-r--r-- | tools/h5repack/h5repack.h | 16 | ||||
-rw-r--r-- | tools/h5repack/h5repack_main.c | 4 | ||||
-rw-r--r-- | tools/h5repack/h5repack_opttable.c | 306 | ||||
-rw-r--r-- | tools/h5repack/h5repack_parse.c | 238 | ||||
-rw-r--r-- | tools/h5repack/h5repacktst.c | 194 |
6 files changed, 602 insertions, 665 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index b915d3a..ef2085c 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -122,35 +122,36 @@ int h5repack_end(pack_opt_t *options) { * *------------------------------------------------------------------------- */ -int h5repack_addfilter(const char* str, pack_opt_t *options) { - obj_list_t *obj_list = NULL; /* one object list for the -f and -l option entry */ - filter_info_t filter; /* filter info for the current -f option entry */ - int n_objs; /* number of objects in the current -f or -l option entry */ - int is_glb; /* is the filter global */ - - /* parse the -f option */ - if (NULL == (obj_list = parse_filter(str, &n_objs, &filter, options, &is_glb))) - return -1; - - /* if it applies to all objects */ - if (is_glb) { - int n; - - n = options->n_filter_g++; /* increase # of global filters */ - - if (options->n_filter_g > H5_REPACK_MAX_NFILTERS) { - error_msg("maximum number of filters exceeded for <%s>\n", str); - HDfree(obj_list); - return -1; - } - - options->filter_g[n] = filter; - } - else - options_add_filter(obj_list, n_objs, filter, options->op_tbl); - - HDfree(obj_list); - return 0; +int +h5repack_addfilter(const char* str, pack_opt_t *options) +{ + obj_list_t *obj_list = NULL; /* one object list for the -f and -l option entry */ + filter_info_t filter; /* filter info for the current -f option entry */ + unsigned n_objs; /* number of objects in the current -f or -l option entry */ + int is_glb; /* is the filter global */ + + /* parse the -f option */ + if (NULL == (obj_list = parse_filter(str, &n_objs, &filter, options, &is_glb))) + return -1; + + /* if it applies to all objects */ + if (is_glb) { + int n; + + n = options->n_filter_g++; /* increase # of global filters */ + if (options->n_filter_g > H5_REPACK_MAX_NFILTERS) { + error_msg("maximum number of filters exceeded for <%s>\n", str); + HDfree(obj_list); + return -1; + } + + options->filter_g[n] = filter; + } + else + options_add_filter(obj_list, n_objs, filter, options->op_tbl); + + HDfree(obj_list); + return 0; } /*------------------------------------------------------------------------- @@ -162,59 +163,53 @@ int h5repack_addfilter(const char* str, pack_opt_t *options) { * *------------------------------------------------------------------------- */ - -int h5repack_addlayout(const char* str, pack_opt_t *options) { - - obj_list_t *obj_list = NULL; /*one object list for the -t and -c option entry */ - int n_objs; /*number of objects in the current -t or -c option entry */ - pack_info_t pack; /*info about layout to extract from parse */ - int j; - int ret_value = -1; - - init_packobject(&pack); - - if (options->all_layout == 1) { - error_msg( - "invalid layout input: 'all' option \ - is present with other objects <%s>\n", - str); - return ret_value; - } - - /* parse the layout option */ - obj_list = parse_layout(str, &n_objs, &pack, options); - if (obj_list) { - - /* set layout option */ - options->layout_g = pack.layout; - - /* no individual dataset specified */ - if (options->all_layout == 1) { - if (pack.layout == H5D_CHUNKED) { - /* -2 means the NONE option, remove chunking - and set the global layout to contiguous */ - if (pack.chunk.rank == -2) { - options->layout_g = H5D_CONTIGUOUS; - } - /* otherwise set the global chunking type */ - else { - options->chunk_g.rank = pack.chunk.rank; - for (j = 0; j < pack.chunk.rank; j++) - options->chunk_g.chunk_lengths[j] = - pack.chunk.chunk_lengths[j]; - } - } - } - - /* individual dataset specified */ - if (options->all_layout == 0) - ret_value = options_add_layout(obj_list, n_objs, &pack, options->op_tbl); - - HDfree(obj_list); - ret_value = 0; - } - - return ret_value; +int +h5repack_addlayout(const char* str, pack_opt_t *options) +{ + obj_list_t *obj_list = NULL; /*one object list for the -t and -c option entry */ + unsigned n_objs; /*number of objects in the current -t or -c option entry */ + pack_info_t pack; /*info about layout to extract from parse */ + int j; + int ret_value = -1; + + init_packobject(&pack); + + if (options->all_layout == 1) { + error_msg( "invalid layout input: 'all' option is present with other objects <%s>\n", str); + return ret_value; + } + + /* parse the layout option */ + obj_list = parse_layout(str, &n_objs, &pack, options); + if (obj_list) { + /* set layout option */ + options->layout_g = pack.layout; + + /* no individual dataset specified */ + if (options->all_layout == 1) { + if (pack.layout == H5D_CHUNKED) { + /* -2 means the NONE option, remove chunking + and set the global layout to contiguous */ + if (pack.chunk.rank == -2) + options->layout_g = H5D_CONTIGUOUS; + /* otherwise set the global chunking type */ + else { + options->chunk_g.rank = pack.chunk.rank; + for (j = 0; j < pack.chunk.rank; j++) + options->chunk_g.chunk_lengths[j] = pack.chunk.chunk_lengths[j]; + } + } + } + + /* individual dataset specified */ + if (options->all_layout == 0) + ret_value = options_add_layout(obj_list, n_objs, &pack, options->op_tbl); + + HDfree(obj_list); + ret_value = 0; + } + + return ret_value; } /* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr() @@ -370,201 +365,201 @@ done: * *------------------------------------------------------------------------- */ -int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, - trav_table_t *travt, pack_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ +int +copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, + trav_table_t *travt, pack_opt_t *options) +{ + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t attr_id = -1; /* attr ID */ - hid_t attr_out = -1; /* attr ID */ - hid_t space_id = -1; /* space ID */ - hid_t ftype_id = -1; /* file type ID */ - hid_t wtype_id = -1; /* read/write type ID */ - size_t msize; /* size of type */ - void *buf = NULL; /* data buffer */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - htri_t is_named; /* Whether the datatype is named */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ - char name[255]; - H5O_info_t oinfo; /* object info */ - int j; - unsigned u; - hbool_t is_ref = 0; - H5T_class_t type_class = -1; - - if (H5Oget_info(loc_in, &oinfo) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Oget_info failed"); - - /*------------------------------------------------------------------------- - * copy all attributes - *------------------------------------------------------------------------- - */ - for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { - /* open attribute */ - if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, - H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); - - /* get name */ - if (H5Aget_name(attr_id, (size_t) 255, name) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); - - /* get the file datatype */ - if ((ftype_id = H5Aget_type(attr_id)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_type failed"); - - /* Check if the datatype is committed */ - if ((is_named = H5Tcommitted(ftype_id)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tcommitted failed"); + hid_t attr_out = -1; /* attr ID */ + hid_t space_id = -1; /* space ID */ + hid_t ftype_id = -1; /* file type ID */ + hid_t wtype_id = -1; /* read/write type ID */ + size_t msize; /* size of type */ + void *buf = NULL; /* data buffer */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + htri_t is_named; /* Whether the datatype is named */ + hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + char name[255]; + H5O_info_t oinfo; /* object info */ + int j; + unsigned u; + hbool_t is_ref = 0; + H5T_class_t type_class = -1; + + if (H5Oget_info(loc_in, &oinfo) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed"); + + /*------------------------------------------------------------------------- + * copy all attributes + *------------------------------------------------------------------------- + */ + for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { + /* open attribute */ + if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); + + /* get name */ + if (H5Aget_name(attr_id, (size_t) 255, name) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + + /* get the file datatype */ + if ((ftype_id = H5Aget_type(attr_id)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed"); + + /* Check if the datatype is committed */ + if ((is_named = H5Tcommitted(ftype_id)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed"); if (is_named && travt) { - hid_t fidout; + hid_t fidout; - /* Create out file id */ - if ((fidout = H5Iget_file_id(loc_out)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Iget_file_id failed"); + /* Create out file id */ + if ((fidout = H5Iget_file_id(loc_out)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iget_file_id failed"); - /* Copy named dt */ - if ((wtype_id = copy_named_datatype(ftype_id, fidout, - named_dt_head_p, travt, options)) < 0) { - H5Fclose(fidout); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_named_datatype failed"); + /* Copy named dt */ + if ((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, travt, options)) < 0) { + H5Fclose(fidout); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed"); } /* end if */ - if (H5Fclose(fidout) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fclose failed"); + if (H5Fclose(fidout) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); } /* end if */ - else { - if (options->use_native == 1) - wtype_id = h5tools_get_native_type(ftype_id); - else - wtype_id = H5Tcopy(ftype_id); - } /* end else */ - - /* get the dataspace handle */ - if ((space_id = H5Aget_space(attr_id)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_space failed"); - - /* get dimensions */ - if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - - nelmts = 1; - for (j = 0; j < rank; j++) - nelmts *= dims[j]; - - if ((msize = H5Tget_size(wtype_id)) == 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_size failed"); - - /*------------------------------------------------------------------------- - * object references are a special case. We cannot just copy the buffers, - * but instead we recreate the reference. - * This is done on a second sweep of the file that just copies the referenced - * objects at copy_refs_attr() - *------------------------------------------------------------------------- - */ - type_class = H5Tget_class(wtype_id); - is_ref = (type_class == H5T_REFERENCE); - if (type_class == H5T_VLEN || type_class == H5T_ARRAY) { - hid_t base_type = -1; - base_type = H5Tget_super(ftype_id); - is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); - H5Tclose(base_type); - } - - if (type_class == H5T_COMPOUND) { - int nmembers = H5Tget_nmembers(wtype_id); - for (j = 0; j < nmembers; j++) { - hid_t mtid = H5Tget_member_type(wtype_id, (unsigned) j); - H5T_class_t mtclass = H5Tget_class(mtid); - H5Tclose(mtid); - - if (mtclass == H5T_REFERENCE) { - is_ref = 1; - break; - } - } /* for (j=0; i<nmembers; j++) */ - } /* if (type_class == H5T_COMPOUND) */ - - if (is_ref) { - ; /* handled by copy_refs_attr() */ - } - else { - /*------------------------------------------------------------------------- - * read to memory - *------------------------------------------------------------------------- - */ - - buf = (void *) HDmalloc((size_t)(nelmts * msize)); - if (buf == NULL) { - error_msg("h5repack", "cannot read into memory\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed"); + else { + if (options->use_native == 1) + wtype_id = h5tools_get_native_type(ftype_id); + else + wtype_id = H5Tcopy(ftype_id); + } /* end else */ + + /* get the dataspace handle */ + if ((space_id = H5Aget_space(attr_id)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space failed"); + + /* get dimensions */ + if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + + nelmts = 1; + for (j = 0; j < rank; j++) + nelmts *= dims[j]; + + if ((msize = H5Tget_size(wtype_id)) == 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + + /*------------------------------------------------------------------------- + * object references are a special case. We cannot just copy the buffers, + * but instead we recreate the reference. + * This is done on a second sweep of the file that just copies the referenced + * objects at copy_refs_attr() + *------------------------------------------------------------------------- + */ + type_class = H5Tget_class(wtype_id); + is_ref = (type_class == H5T_REFERENCE); + if (type_class == H5T_VLEN || type_class == H5T_ARRAY) { + hid_t base_type = -1; + + base_type = H5Tget_super(ftype_id); + is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); + H5Tclose(base_type); + } + + if (type_class == H5T_COMPOUND) { + int nmembers = H5Tget_nmembers(wtype_id); + + for (j = 0; j < nmembers; j++) { + hid_t mtid = H5Tget_member_type(wtype_id, (unsigned) j); + H5T_class_t mtclass = H5Tget_class(mtid); + H5Tclose(mtid); + + if (mtclass == H5T_REFERENCE) { + is_ref = 1; + break; + } + } /* for (j=0; i<nmembers; j++) */ + } /* if (type_class == H5T_COMPOUND) */ + + if (is_ref) { + ; /* handled by copy_refs_attr() */ + } + else { + /*------------------------------------------------------------------------- + * read to memory + *------------------------------------------------------------------------- + */ + + buf = (void *) HDmalloc((size_t)(nelmts * msize)); + if (buf == NULL) { + error_msg("h5repack", "cannot read into memory\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); } /* end if */ - if (H5Aread(attr_id, wtype_id, buf) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed"); + if (H5Aread(attr_id, wtype_id, buf) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed"); - /*------------------------------------------------------------------------- - * copy - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * copy + *------------------------------------------------------------------------- + */ - if ((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, - H5P_DEFAULT, H5P_DEFAULT)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Acreate2 failed"); + if ((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Acreate2 failed"); if (H5Awrite(attr_out, wtype_id, buf) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Awrite failed"); - - /*close*/ - if (H5Aclose(attr_out) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose failed"); - - /* Check if we have VL data and string in the attribute's datatype that must - * be reclaimed */ - if (TRUE == h5tools_detect_vlen(wtype_id)) - H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf); - HDfree(buf); - buf = NULL; - } /*H5T_REFERENCE*/ - - if (options->verbose) - printf(FORMAT_OBJ_ATTR, "attr", name); - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - if (H5Tclose(ftype_id) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Awrite failed"); + + /*close*/ + if (H5Aclose(attr_out) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); + + /* Check if we have VL data and string in the attribute's datatype that must + * be reclaimed */ + if (TRUE == h5tools_detect_vlen(wtype_id)) + H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf); + HDfree(buf); + buf = NULL; + } /*H5T_REFERENCE*/ + + if (options->verbose) + printf(FORMAT_OBJ_ATTR, "attr", name); + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + + if (H5Tclose(ftype_id) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); if (H5Tclose(wtype_id) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); if (H5Sclose(space_id) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); if (H5Aclose(attr_id) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); } /* u */ - return 0; + return 0; done: - H5E_BEGIN_TRY - { - if (buf) { - /* Check if we have VL data and string in the attribute's datatype that must - * be reclaimed */ - if (TRUE == h5tools_detect_vlen(wtype_id)) - H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf); - - /* Free buf */ - HDfree(buf); - } /* end if */ + H5E_BEGIN_TRY { + if (buf) { + /* Check if we have VL data and string in the attribute's datatype that must + * be reclaimed */ + if (TRUE == h5tools_detect_vlen(wtype_id)) + H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf); + + /* Free buf */ + HDfree(buf); + } /* end if */ - H5Tclose(ftype_id); - H5Tclose(wtype_id); - H5Sclose(space_id); - H5Aclose(attr_id); - H5Aclose(attr_out); - } H5E_END_TRY; + H5Tclose(ftype_id); + H5Tclose(wtype_id); + H5Sclose(space_id); + H5Aclose(attr_id); + H5Aclose(attr_out); + } H5E_END_TRY; - return ret_value; + return ret_value; } /* end copy_attr() */ /*------------------------------------------------------------------------- diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 329be1f..d2ab923 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -82,9 +82,9 @@ typedef struct { /* store a table of all objects */ typedef struct { - unsigned int size; - unsigned int nelems; - pack_info_t *objs; + unsigned int size; + unsigned int nelems; + pack_info_t *objs; } pack_opttbl_t; @@ -114,7 +114,7 @@ typedef struct { hsize_t ublock_size; /* user block size */ hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */ hsize_t threshold; /* alignment threshold for H5Pset_alignment */ - hsize_t alignment ; /* alignment for H5Pset_alignment */ + hsize_t alignment; /* alignment for H5Pset_alignment */ H5F_file_space_type_t fs_strategy; /* File space handling strategy */ hsize_t fs_threshold; /* Free space section threshold */ } pack_opt_t; @@ -210,11 +210,11 @@ int apply_filters(const char* name, /* object name from traverse list */ int options_table_init( pack_opttbl_t **tbl ); int options_table_free( pack_opttbl_t *table ); int options_add_layout( obj_list_t *obj_list, - int n_objs, + unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table ); int options_add_filter ( obj_list_t *obj_list, - int n_objs, + unsigned n_objs, filter_info_t filt, pack_opttbl_t *table ); pack_info_t* options_get_object( const char *path, @@ -226,13 +226,13 @@ pack_info_t* options_get_object( const char *path, */ obj_list_t* parse_filter(const char *str, - int *n_objs, + unsigned *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb); obj_list_t* parse_layout(const char *str, - int *n_objs, + unsigned *n_objs, pack_info_t *pack, /* info about object */ pack_opt_t *options); diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index e903435..0998f20 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -428,7 +428,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) { break; case 'm': - options->min_comp = HDatoi( opt_arg ); + options->min_comp = HDstrtoull(opt_arg , NULL, 0); if ((int) options->min_comp <= 0) { error_msg("invalid minimum compress size <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); @@ -515,7 +515,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) { break; case 'a': - options->alignment = HDatol( opt_arg ); + options->alignment = HDstrtoull(opt_arg , NULL, 0); if (options->alignment < 1) { error_msg("invalid alignment size\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index b54e887..8c98b76 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.c @@ -105,21 +105,22 @@ static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, * *------------------------------------------------------------------------- */ - -static int aux_inctable(pack_opttbl_t *table, int n_objs) { - unsigned int i; - - table->size += n_objs; - table->objs = - (pack_info_t*) HDrealloc(table->objs, table->size * sizeof(pack_info_t)); - if (table->objs == NULL) { - error_msg("not enough memory for options table\n"); - return -1; - } - for (i = table->nelems; i < table->size; i++) { - init_packobject(&table->objs[i]); - } - return 0; +static int +aux_inctable(pack_opttbl_t *table, unsigned n_objs) +{ + unsigned u; + + table->size += n_objs; + table->objs = (pack_info_t*) HDrealloc(table->objs, table->size * sizeof(pack_info_t)); + if (table->objs == NULL) { + error_msg("not enough memory for options table\n"); + return -1; + } + + for (u = table->nelems; u < table->size; u++) + init_packobject(&table->objs[u]); + + return 0; } @@ -183,80 +184,77 @@ int options_table_free(pack_opttbl_t *table) { * *------------------------------------------------------------------------- */ - -int options_add_layout(obj_list_t *obj_list, int n_objs, pack_info_t *pack, - pack_opttbl_t *table) { - unsigned int i, I; - int j, added = 0, found = 0; - - /* increase the size of the collection by N_OBJS if necessary */ - if (table->nelems + n_objs >= table->size) { - if (aux_inctable(table, n_objs) < 0) - return -1; - } - - /* search if this object is already in the table; "path" is the key */ - if (table->nelems > 0) { - /* go tru the supplied list of names */ - for (j = 0; j < n_objs; j++) { - /* linear table search */ - for (i = 0; i < table->nelems; i++) { - /*already on the table */ - if (HDstrcmp(obj_list[j].obj,table->objs[i].path) == 0) { - /* already chunk info inserted for this one; exit */ - if (table->objs[i].chunk.rank > 0) { - error_msg( - "chunk information already inserted for <%s>\n", - obj_list[j].obj); - HDexit(EXIT_FAILURE); - } - /* insert the layout info */ - else { - aux_tblinsert_layout(table, i, pack); - found = 1; - break; - } - } /* if */ - } /* i */ - - if (found == 0) { - /* keep the grow in a temp var */ - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_layout(table, I, pack); - } - /* cases where we have an already inserted name but there is a new name also - example: - -f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20 - dset1 is already inserted, but dset2 must also be - */ - else if (found == 1 - && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) { - /* keep the grow in a temp var */ - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_layout(table, I, pack); - } - } /* j */ - } - - /* first time insertion */ - else { - /* go tru the supplied list of names */ - for (j = 0; j < n_objs; j++) { - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_layout(table, I, pack); - - } - } - - table->nelems += added; - - return 0; +int +options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, + pack_opttbl_t *table) +{ + unsigned i, j, I; + unsigned added = 0; + hbool_t found = FALSE; + + /* increase the size of the collection by N_OBJS if necessary */ + if (table->nelems + n_objs >= table->size) + if (aux_inctable(table, n_objs) < 0) + return -1; + + /* search if this object is already in the table; "path" is the key */ + if (table->nelems > 0) { + /* go tru the supplied list of names */ + for (j = 0; j < n_objs; j++) { + /* linear table search */ + for (i = 0; i < table->nelems; i++) { + /*already on the table */ + if (HDstrcmp(obj_list[j].obj,table->objs[i].path) == 0) { + /* already chunk info inserted for this one; exit */ + if (table->objs[i].chunk.rank > 0) { + error_msg("chunk information already inserted for <%s>\n", obj_list[j].obj); + HDexit(EXIT_FAILURE); + } + /* insert the layout info */ + else { + aux_tblinsert_layout(table, i, pack); + found = TRUE; + break; + } + } /* if */ + } /* i */ + + if (!found) { + /* keep the grow in a temp var */ + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_layout(table, I, pack); + } + /* cases where we have an already inserted name but there is a new name also + example: + -f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20 + dset1 is already inserted, but dset2 must also be + */ + else + if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) { + /* keep the grow in a temp var */ + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_layout(table, I, pack); + } + } /* j */ + } + /* first time insertion */ + else { + /* go tru the supplied list of names */ + for (j = 0; j < n_objs; j++) { + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_layout(table, I, pack); + } + } + + table->nelems += added; + + return 0; } /*------------------------------------------------------------------------- @@ -268,71 +266,71 @@ int options_add_layout(obj_list_t *obj_list, int n_objs, pack_info_t *pack, * *------------------------------------------------------------------------- */ - -int options_add_filter(obj_list_t *obj_list, int n_objs, filter_info_t filt, - pack_opttbl_t *table) { - - unsigned int i, I; - int j, added = 0, found = 0; - - /* increase the size of the collection by N_OBJS if necessary */ - if (table->nelems + n_objs >= table->size) { - if (aux_inctable(table, n_objs) < 0) - return -1; - } - - /* search if this object is already in the table; "path" is the key */ - if (table->nelems > 0) { - /* go tru the supplied list of names */ - for (j = 0; j < n_objs; j++) { - /* linear table search */ - for (i = 0; i < table->nelems; i++) { - /*already on the table */ - if (HDstrcmp(obj_list[j].obj,table->objs[i].path) == 0) { - /* insert */ - aux_tblinsert_filter(table, i, filt); - found = 1; - break; - } /* if */ - } /* i */ - - if (found == 0) { - /* keep the grow in a temp var */ - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_filter(table, I, filt); - } - /* cases where we have an already inserted name but there is a new name also - example: - -l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1 - dset1 is already inserted, but dset2 must also be - */ - else if (found == 1 - && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) { - /* keep the grow in a temp var */ - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_filter(table, I, filt); - } - } /* j */ - } - - /* first time insertion */ - else { - /* go tru the supplied list of names */ - for (j = 0; j < n_objs; j++) { - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_filter(table, I, filt); - } - } - - table->nelems += added; - - return 0; +int +options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, + pack_opttbl_t *table) +{ + unsigned int i, j, I; + unsigned added = 0; + hbool_t found = FALSE; + + /* increase the size of the collection by N_OBJS if necessary */ + if (table->nelems + n_objs >= table->size) + if (aux_inctable(table, n_objs) < 0) + return -1; + + /* search if this object is already in the table; "path" is the key */ + if (table->nelems > 0) { + /* go tru the supplied list of names */ + for (j = 0; j < n_objs; j++) { + /* linear table search */ + for (i = 0; i < table->nelems; i++) { + /*already on the table */ + if (HDstrcmp(obj_list[j].obj, table->objs[i].path) == 0) { + /* insert */ + aux_tblinsert_filter(table, i, filt); + found = TRUE; + break; + } /* if */ + } /* i */ + + if (!found) { + /* keep the grow in a temp var */ + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_filter(table, I, filt); + } + /* cases where we have an already inserted name but there is a new name also + example: + -l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1 + dset1 is already inserted, but dset2 must also be + */ + else + if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) { + /* keep the grow in a temp var */ + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_filter(table, I, filt); + } + } /* j */ + } + + /* first time insertion */ + else { + /* go tru the supplied list of names */ + for (j = 0; j < n_objs; j++) { + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_filter(table, I, filt); + } + } + + table->nelems += added; + + return 0; } /*------------------------------------------------------------------------- diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index 1d71c13..c65a311 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -44,23 +44,22 @@ * *------------------------------------------------------------------------- */ - - obj_list_t* parse_filter(const char *str, - int *n_objs, + unsigned *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb) { - unsigned i, u; + size_t i, m, u; char c; - size_t len=HDstrlen(str); - int j, m, n, k, l, p, r, q, end_obj=-1, no_param=0; + size_t len = HDstrlen(str); + int k, l, p, r, q, end_obj = -1, no_param = 0; + unsigned j, n; char sobj[MAX_NC_NAME]; char scomp[10]; char stype[6]; char smask[3]; - obj_list_t* obj_list=NULL; + obj_list_t* obj_list = NULL; unsigned pixels_per_block; @@ -69,66 +68,60 @@ obj_list_t* parse_filter(const char *str, *is_glb = 0; /* check for the end of object list and number of objects */ - for ( i = 0, n = 0; i < len; i++) - { + for(i = 0, n = 0; i < len; i++) { c = str[i]; - if ( c==':' ) - { - end_obj=i; - } - if ( c==',' ) - { + if(c == ':') + end_obj = (int)i; + if(c == ',') n++; - } } - if (end_obj==-1) /* missing : */ - { + /* Check for missing : */ + if(end_obj == -1) { /* apply to all objects */ - options->all_filter=1; + options->all_filter = 1; *is_glb = 1; } n++; - obj_list = (obj_list_t*) HDmalloc(n*sizeof(obj_list_t)); - if (obj_list==NULL) - { + obj_list = (obj_list_t *)HDmalloc(n * sizeof(obj_list_t)); + if(obj_list == NULL) { error_msg("could not allocate object list\n"); return NULL; } - *n_objs=n; + *n_objs = n; /* get object list */ - for ( j = 0, k = 0, n = 0; j < end_obj; j++, k++) - { - c = str[j]; - sobj[k] = c; - if ( c==',' || j==end_obj-1) - { - if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0'; - HDstrcpy(obj_list[n].obj,sobj); - HDmemset(sobj,0,sizeof(sobj)); - n++; - k=-1; + if(end_obj > 0) + for(j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) { + c = str[j]; + sobj[k] = c; + if(c == ',' || j == (unsigned)(end_obj - 1)) { + if(c==',') + sobj[k]='\0'; + else + sobj[k+1]='\0'; + HDstrcpy(obj_list[n].obj,sobj); + HDmemset(sobj,0,sizeof(sobj)); + n++; + k=-1; + } } - } /* nothing after : */ - if (end_obj+1==(int)len) - { - if (obj_list) HDfree(obj_list); + if(end_obj + 1 == (int)len) { + if(obj_list) + HDfree(obj_list); error_msg("input Error: Invalid compression type in <%s>\n",str); HDexit(EXIT_FAILURE); } /* get filter additional parameters */ - m=0; - for ( i=end_obj+1, k=0, j=0; i<len; i++,k++) - { + m = 0; + for(i = (size_t)(end_obj + 1), k = 0, j = 0; i < len; i++, k++) { c = str[i]; - scomp[k]=c; - if ( c=='=' || i==len-1) - { + scomp[k] = c; + if(c == '=' || i == len - 1) { if ( c=='=') /*one more parameter */ { scomp[k]='\0'; /*cut space */ @@ -143,38 +136,32 @@ obj_list_t* parse_filter(const char *str, if (HDstrcmp(scomp,"SZIP")==0) { l=-1; /* mask index check */ - for ( m=0,u=i+1; u<len; u++,m++) - { - if (str[u]==',') - { + for(m = 0, u = i + 1; u < len; u++, m++) { + if(str[u] == ',') { stype[m]='\0'; /* end digit of szip */ l=0; /* start EC or NN search */ u++; /* skip ',' */ } c = str[u]; - if (!isdigit(c) && l==-1) - { + if(!HDisdigit(c) && l == -1) { if (obj_list) HDfree(obj_list); error_msg("compression parameter not digit in <%s>\n",str); HDexit(EXIT_FAILURE); } if (l==-1) stype[m]=c; - else - { - smask[l]=c; + else { + smask[l] = c; l++; - if (l==2) - { - smask[l]='\0'; - i=len-1; /* end */ + if(l == 2) { + smask[l] = '\0'; + i = len - 1; /* end */ (*n_objs)--; /* we counted an extra ',' */ if (HDstrcmp(smask,"NN")==0) filt->cd_values[j++]=H5_SZIP_NN_OPTION_MASK; else if (HDstrcmp(smask,"EC")==0) filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK; - else - { + else { error_msg("szip mask must be 'NN' or 'EC' \n"); HDexit(EXIT_FAILURE); } @@ -213,7 +200,7 @@ obj_list_t* parse_filter(const char *str, u++; /* skip ',' */ } c = str[u]; - if (!isdigit(c) && l==-1) + if (!HDisdigit(c) && l==-1) { if (obj_list) HDfree(obj_list); error_msg("compression parameter is not a digit in <%s>\n",str); @@ -258,40 +245,34 @@ obj_list_t* parse_filter(const char *str, l=-1; /* filter number index check */ p=-1; /* CD_VAL count check */ r=-1; /* CD_VAL check */ - for ( m=0,q=0,u=i+1; u<len; u++,m++,q++) - { - if (str[u]==',') - { + for(m = 0, q = 0, u = i + 1; u < len; u++, m++, q++) { + if(str[u] == ',') { stype[q]='\0'; /* end digit */ - if (l==-1) - { - filt->filtn=atoi(stype); - l=0; + if(l == -1) { + filt->filtn = HDatoi(stype); + l = 0; } - else if (p==-1) - { - filt->cd_nelmts=atoi(stype); - p=0; + else if(p == -1) { + filt->cd_nelmts = HDstrtoull(stype , NULL, 0); + p = 0; } else - r=0; - q=0; + r = 0; + q = 0; u++; /* skip ',' */ } c = str[u]; - if (!isdigit(c) && l==-1) - { - if (obj_list) HDfree(obj_list); + if(!HDisdigit(c) && l == -1) { + if(obj_list) + HDfree(obj_list); error_msg("filter number parameter is not a digit in <%s>\n",str); HDexit(EXIT_FAILURE); } - stype[q]=c; - if (l==0 && p==0) - { - if (r==0) - filt->cd_values[j++]=atoi(stype); + stype[q] = c; + if(l == 0 && p == 0) { + if(r == 0) + filt->cd_values[j++] = (unsigned)HDstrtoul(stype , NULL, 0); } - } /* u */ stype[q]='\0'; @@ -309,7 +290,7 @@ obj_list_t* parse_filter(const char *str, for ( m=0,u=i+1; u<len; u++,m++) { c = str[u]; - if (!isdigit(c)){ + if (!HDisdigit(c)){ if (obj_list) HDfree(obj_list); error_msg("compression parameter is not a digit in <%s>\n",str); HDexit(EXIT_FAILURE); @@ -320,9 +301,7 @@ obj_list_t* parse_filter(const char *str, stype[m]='\0'; } /*if */ - - - filt->cd_values[j++]=atoi(stype); + filt->cd_values[j++] = (unsigned)HDstrtoul(stype , NULL, 0); i+=m; /* jump */ } else if (i==len-1) @@ -442,17 +421,18 @@ obj_list_t* parse_filter(const char *str, * User Defined Filter *------------------------------------------------------------------------- */ - else if (HDstrcmp(scomp,"UD")==0) - { - if (filt->cd_nelmts != j) - { /* parameters does not match count */ - if (obj_list) HDfree(obj_list); + else if(HDstrcmp(scomp, "UD") == 0) { + /* parameters does not match count */ + if(filt->cd_nelmts != j) { + if(obj_list) + HDfree(obj_list); error_msg("incorrect number of compression parameters in <%s>\n",str); HDexit(EXIT_FAILURE); } } else { - if (obj_list) HDfree(obj_list); + if(obj_list) + HDfree(obj_list); error_msg("invalid filter type in <%s>\n",str); HDexit(EXIT_FAILURE); } @@ -516,8 +496,7 @@ obj_list_t* parse_filter(const char *str, return obj_list; } - - + /*------------------------------------------------------------------------- * Function: parse_layout * @@ -540,36 +519,30 @@ obj_list_t* parse_filter(const char *str, *------------------------------------------------------------------------- */ obj_list_t* parse_layout(const char *str, - int *n_objs, + unsigned *n_objs, pack_info_t *pack, /* info about layout needed */ pack_opt_t *options) { - obj_list_t* obj_list=NULL; - unsigned i; + obj_list_t* obj_list = NULL; + unsigned i, j, n; char c; - size_t len=HDstrlen(str); - int j, n, k, end_obj=-1, c_index; + size_t len = HDstrlen(str); + int k, end_obj = -1, c_index; char sobj[MAX_NC_NAME]; char sdim[10]; char slayout[10]; - HDmemset(sdim, '\0', sizeof(sdim)); HDmemset(sobj, '\0', sizeof(sobj)); HDmemset(slayout, '\0', sizeof(slayout)); /* check for the end of object list and number of objects */ - for ( i=0, n=0; i<len; i++) - { + for(i = 0, n = 0; i < len; i++) { c = str[i]; - if ( c==':' ) - { - end_obj=i; - } - if ( c==',' ) - { + if(c == ':') + end_obj = (int)i; + if(c == ',') n++; - } } if (end_obj==-1) { /* missing : chunk all */ @@ -577,28 +550,30 @@ obj_list_t* parse_layout(const char *str, } n++; - obj_list = (obj_list_t*) HDmalloc(n*sizeof(obj_list_t)); + obj_list = (obj_list_t*)HDmalloc(n * sizeof(obj_list_t)); if (obj_list==NULL) { error_msg("could not allocate object list\n"); return NULL; } - *n_objs=n; + *n_objs = n; /* get object list */ - for ( j=0, k=0, n=0; j<end_obj; j++,k++) - { - c = str[j]; - sobj[k]=c; - if ( c==',' || j==end_obj-1) - { - if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0'; - HDstrcpy(obj_list[n].obj,sobj); - HDmemset(sobj,0,sizeof(sobj)); - n++; - k=-1; + if(end_obj > 0) + for(j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) { + c = str[j]; + sobj[k] = c; + if(c == ',' || j == (unsigned)(end_obj - 1)) { + if(c == ',') + sobj[k] = '\0'; + else + sobj[k + 1] = '\0'; + HDstrcpy(obj_list[n].obj,sobj); + HDmemset(sobj,0,sizeof(sobj)); + n++; + k=-1; + } } - } /* nothing after : */ if (end_obj+1==(int)len) @@ -609,8 +584,7 @@ obj_list_t* parse_layout(const char *str, } /* get layout info */ - for ( j=end_obj+1, n=0; n<=5; j++,n++) - { + for(j = (unsigned)(end_obj + 1), n = 0; n <= 5; j++, n++) { if (n==5) { slayout[n]='\0'; /*cut string */ @@ -642,20 +616,18 @@ obj_list_t* parse_layout(const char *str, */ k=0; - if (j>(int)len) - { + if(j > len) { if (obj_list) HDfree(obj_list); error_msg("in parse layout, <%s> Chunk dimensions missing\n",str); HDexit(EXIT_FAILURE); } - for ( i=j, c_index=0; i<len; i++) - { + for(i = j, c_index = 0; i < len; i++) { c = str[i]; sdim[k]=c; k++; /*increment sdim index */ - if (!isdigit(c) && c!='x' + if (!HDisdigit(c) && c!='x' && c!='N' && c!='O' && c!='N' && c!='E' ){ if (obj_list) HDfree(obj_list); @@ -669,7 +641,7 @@ obj_list_t* parse_layout(const char *str, if ( c=='x') { sdim[k-1]='\0'; k=0; - pack->chunk.chunk_lengths[c_index]=atoi(sdim); + pack->chunk.chunk_lengths[c_index] = HDstrtoull(sdim , NULL, 0); if (pack->chunk.chunk_lengths[c_index]==0) { if (obj_list) HDfree(obj_list); error_msg("in parse layout, <%s> conversion to number in <%s>\n", @@ -687,7 +659,7 @@ obj_list_t* parse_layout(const char *str, } else { - pack->chunk.chunk_lengths[c_index]=atoi(sdim); + pack->chunk.chunk_lengths[c_index] = HDstrtoull(sdim , NULL, 0); if (pack->chunk.chunk_lengths[c_index]==0){ if (obj_list) HDfree(obj_list); error_msg("in parse layout, <%s> conversion to number in <%s>\n", diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 07ea676..82b45fc 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -3421,7 +3421,7 @@ make_userblock(void) /* Initialize userblock data */ for(u = 0; u < USERBLOCK_SIZE; u++) - ub[u] = 'a' + (char)(u % 26); + ub[u] = (char)('a' + (char)(u % 26)); /* Re-open HDF5 file, as "plain" file */ if((fd = HDopen(FNAME16, O_WRONLY, 0644)) < 0) @@ -3534,7 +3534,7 @@ make_userblock_file(void) /* initialize userblock data */ for(u = 0; u < USERBLOCK_SIZE; u++) - ub[u] = 'a' + (char)(u % 26); + ub[u] = (char)('a' + (char)(u % 26)); /* open file */ if((fd = HDopen(FNAME_UB,O_WRONLY|O_CREAT|O_TRUNC, 0644 )) < 0) @@ -3591,7 +3591,8 @@ int write_dset_in(hid_t loc_id, hid_t sid=-1; hid_t tid=-1; hid_t pid=-1; - int val, i, j, k, n; + unsigned i, j; + int val, k, n; float f; /* create 1D attributes with dimension [2], 2 elements */ @@ -3646,13 +3647,10 @@ int write_dset_in(hid_t loc_id, */ - if (make_diffs) - { - for (i=0; i<2; i++) - for (j=0; j<2; j++) - { - buf1[i][j]='z'; - } + if(make_diffs) { + for(i = 0; i < 2; i++) + for(j = 0; j < 2; j++) + buf1[i][j] = 'z'; } @@ -3675,10 +3673,9 @@ int write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - if (make_diffs) - { - for (i=0; i<2; i++) - buf2[i]=buf2[1]=0; + if(make_diffs) { + for(i = 0; i < 2; i++) + buf2[i] = buf2[1] = 0; } if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) @@ -3693,11 +3690,10 @@ int write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - if (make_diffs) - { - for (i=0; i<2; i++) - { - buf3[i].a=0; buf3[i].b=0; + if(make_diffs) { + for(i = 0; i < 2; i++) { + buf3[i].a = 0; + buf3[i].b = 0; } } @@ -3716,12 +3712,9 @@ int write_dset_in(hid_t loc_id, */ - if (make_diffs) - { - for (i=0; i<2; i++) - { - buf45[i]=GREEN; - } + if(make_diffs) { + for(i = 0; i < 2; i++) + buf45[i] = GREEN; } if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) @@ -3813,13 +3806,10 @@ int write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - if (make_diffs) - { - for (i=0; i<2; i++) - for (j=0; j<3; j++) - { - buf6[i][j]=0; - } + if(make_diffs) { + for(i = 0; i < 2; i++) + for(j = 0; j < 3; j++) + buf6[i][j] = 0; } if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) @@ -3880,12 +3870,10 @@ int write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - if (make_diffs) - { - for (i=0; i<2; i++) - { - buf7[i]=0; - buf8[i]=0; + if(make_diffs) { + for(i = 0; i < 2; i++) { + buf7[i] = 0; + buf8[i] = 0; } } @@ -4008,16 +3996,13 @@ int write_dset_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ n = 0; - for(i = 0; i < 3; i++) - { - for(j = 0; j < 2; j++) - { - int l; + for(i = 0; i < 3; i++) { + for(j = 0; j < 2; j++) { + unsigned l; buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) - { + for(l = 0; l < i + 1; l++) { if(make_diffs) ((int *)buf52[i][j].p)[l] = 0; else @@ -4128,11 +4113,13 @@ int write_dset_in(hid_t loc_id, n=1; - for (i = 0; i < 4; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 2; k++) { - if (make_diffs) buf23[i][j][k]=0; - else buf23[i][j][k]=n++; + for(i = 0; i < 4; i++) { + for(j = 0; j < 3; j++) { + for(k = 0; k < 2; k++) { + if(make_diffs) + buf23[i][j][k] = 0; + else + buf23[i][j][k] = (char)(n++); } } } @@ -4164,16 +4151,16 @@ int write_dset_in(hid_t loc_id, */ n=1; - for (i = 0; i < 4; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 2; k++) { - if (make_diffs) { - buf33[i][j][k].a=0; - buf33[i][j][k].b=0; + for(i = 0; i < 4; i++) { + for(j = 0; j < 3; j++) { + for(k = 0; k < 2; k++) { + if(make_diffs) { + buf33[i][j][k].a = 0; + buf33[i][j][k].b = 0; } else { - buf33[i][j][k].a=n++; - buf33[i][j][k].b=n++; + buf33[i][j][k].a = (char)(n++); + buf33[i][j][k].b = n++; } } } @@ -4227,18 +4214,14 @@ int write_dset_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ n = 0; - for(i = 0; i < 4; i++) - { - for(j = 0; j < 3; j++) - { - for(k = 0; k < 2; k++) - { - int l; + for(i = 0; i < 4; i++) { + for(j = 0; j < 3; j++) { + for(k = 0; k < 2; k++) { + unsigned l; buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) - { + for(l = 0; l < i + 1; l++) { if(make_diffs) ((int *)buf53[i][j][k].p)[l] = 0; else @@ -4274,10 +4257,8 @@ int write_dset_in(hid_t loc_id, n = 1; - for(i = 0; i < 24; i++) - { - for(j = 0; j < (int)dimarray[0]; j++) - { + for(i = 0; i < 24; i++) { + for(j = 0; j < dimarray[0]; j++) { if(make_diffs) buf63[i][j] = 0; else @@ -4316,13 +4297,10 @@ int write_dset_in(hid_t loc_id, if (write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0) goto out; - return 0; - out: - H5E_BEGIN_TRY - { + H5E_BEGIN_TRY { H5Pclose(pid); H5Sclose(sid); H5Dclose(did); @@ -4471,7 +4449,8 @@ int write_attr_in(hid_t loc_id, hid_t aid = -1; hid_t sid = -1; hid_t tid = -1; - int val, i, j, k, n; + int val, j, k, n; + unsigned i; float f; /* create 1D attributes with dimension [2], 2 elements */ @@ -5021,16 +5000,17 @@ int write_attr_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ n=0; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 2; j++) - { - int l; + for(i = 0; i < 3; i++) { + for(j = 0; j < 2; j++) { + unsigned l; + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for (l = 0; l < i + 1; l++) - if (make_diffs)((int *)buf52[i][j].p)[l] = 0; - else ((int *)buf52[i][j].p)[l] = n++; + for(l = 0; l < i + 1; l++) + if(make_diffs) + ((int *)buf52[i][j].p)[l] = 0; + else + ((int *)buf52[i][j].p)[l] = n++; } } @@ -5239,14 +5219,13 @@ int write_attr_in(hid_t loc_id, */ n=1; - for (i = 0; i < 4; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 2; k++) - { - if (make_diffs) buf23[i][j][k]=0; - else buf23[i][j][k]=n++; + for(i = 0; i < 4; i++) { + for(j = 0; j < 3; j++) { + for(k = 0; k < 2; k++) { + if(make_diffs) + buf23[i][j][k] = 0; + else + buf23[i][j][k] = (char)(n++); } } } @@ -5308,21 +5287,16 @@ int write_attr_in(hid_t loc_id, */ n=1; - for (i = 0; i < 4; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 2; k++) - { - if (make_diffs) - { - buf33[i][j][k].a=0; - buf33[i][j][k].b=0; + for(i = 0; i < 4; i++) { + for(j = 0; j < 3; j++) { + for(k = 0; k < 2; k++) { + if(make_diffs) { + buf33[i][j][k].a = 0; + buf33[i][j][k].b = 0; } - else - { - buf33[i][j][k].a=n++; - buf33[i][j][k].b=n++; + else { + buf33[i][j][k].a = (char)(n++); + buf33[i][j][k].b = n++; } } } @@ -5491,14 +5465,13 @@ int write_attr_in(hid_t loc_id, { for (k = 0; k < 2; k++) { - int l; + unsigned l; + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)i + 1; for (l = 0; l < i + 1; l++) if (make_diffs) - { ((int *)buf53[i][j][k].p)[l] = 0; - } else ((int *)buf53[i][j][k].p)[l] = n++; } @@ -5622,8 +5595,7 @@ int write_attr_in(hid_t loc_id, return 0; out: - H5E_BEGIN_TRY - { + H5E_BEGIN_TRY { H5Aclose(aid); H5Sclose(sid); H5Tclose(tid); |