diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2011-02-14 22:20:32 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2011-02-14 22:20:32 (GMT) |
commit | 23a80ac554229f2f0163f1a92a02b921bb6c5e29 (patch) | |
tree | cb3558dfe2edb82633f2dd3ad983f753aa519443 | |
parent | 1c625e6ad97a230fb7baec5a024c47e275a9ee4c (diff) | |
download | hdf5-23a80ac554229f2f0163f1a92a02b921bb6c5e29.zip hdf5-23a80ac554229f2f0163f1a92a02b921bb6c5e29.tar.gz hdf5-23a80ac554229f2f0163f1a92a02b921bb6c5e29.tar.bz2 |
[svn-r20103] Purpose:
Change to use HDxxx macros.
Description:
Originally this started for fixing incorrect pointer usage. But that got
fixed through coverity merge. So this is mainly changing to use HDxxx
macros and clean up some related code.
Tested:
jam (linux32-LE), amani (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE)
-rw-r--r-- | tools/h5repack/h5repack.h | 3 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 36 | ||||
-rw-r--r-- | tools/h5repack/h5repack_filters.c | 4 | ||||
-rw-r--r-- | tools/h5repack/h5repack_main.c | 34 | ||||
-rw-r--r-- | tools/h5repack/h5repack_opttable.c | 26 | ||||
-rw-r--r-- | tools/h5repack/h5repack_parse.c | 45 | ||||
-rw-r--r-- | tools/h5repack/h5repack_refs.c | 5 |
7 files changed, 66 insertions, 87 deletions
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 4d601ec..6415d3a 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -17,8 +17,7 @@ #ifndef H5REPACK_H__ #define H5REPACK_H__ -#include <assert.h> -#include <string.h> +#include "H5private.h" #include "hdf5.h" #include "h5trav.h" diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index f849697..5153cc4 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -13,11 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdlib.h> -#include <string.h> -#include <stdio.h> #include "h5repack.h" -#include "H5private.h" #include "h5tools.h" #include "h5tools_utils.h" @@ -689,7 +685,7 @@ int do_copy_objects(hid_t fidin, /* check if filters were requested for individual objects */ for (u = 0; u < options->op_tbl->nelems; u++) { - if (strcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0) { + if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0) { if (options->op_tbl->objs[u].filter->filtn > 0) { req_filter = 1; } @@ -1221,7 +1217,7 @@ static void print_dataset_info(hid_t dcpl_id, int i; - strcpy(strfilter,"\0"); + HDstrcpy(strfilter,"\0"); /* get information about input filters */ if((nfilters = H5Pget_nfilters(dcpl_id)) < 0) @@ -1238,51 +1234,51 @@ static void print_dataset_info(hid_t dcpl_id, break; case H5Z_FILTER_DEFLATE: - strcat(strfilter,"GZIP "); + HDstrcat(strfilter,"GZIP "); #if defined (PRINT_DEBUG) { unsigned level=cd_values[0]; sprintf(temp,"(%d)",level); - strcat(strfilter,temp); + HDstrcat(strfilter,temp); } #endif break; case H5Z_FILTER_SZIP: - strcat(strfilter,"SZIP "); + HDstrcat(strfilter,"SZIP "); #if defined (PRINT_DEBUG) { unsigned options_mask=cd_values[0]; /* from dcpl, not filt*/ unsigned ppb=cd_values[1]; sprintf(temp,"(%d,",ppb); - strcat(strfilter,temp); + HDstrcat(strfilter,temp); if (options_mask & H5_SZIP_EC_OPTION_MASK) - strcpy(temp,"EC) "); + HDstrcpy(temp,"EC) "); else if (options_mask & H5_SZIP_NN_OPTION_MASK) - strcpy(temp,"NN) "); + HDstrcpy(temp,"NN) "); } - strcat(strfilter,temp); + HDstrcat(strfilter,temp); #endif break; case H5Z_FILTER_SHUFFLE: - strcat(strfilter,"SHUF "); + HDstrcat(strfilter,"SHUF "); break; case H5Z_FILTER_FLETCHER32: - strcat(strfilter,"FLET "); + HDstrcat(strfilter,"FLET "); break; case H5Z_FILTER_NBIT: - strcat(strfilter,"NBIT "); + HDstrcat(strfilter,"NBIT "); break; case H5Z_FILTER_SCALEOFFSET: - strcat(strfilter,"SCALEOFFSET "); + HDstrcat(strfilter,"SCALEOFFSET "); break; } /* switch */ }/*i*/ @@ -1292,10 +1288,10 @@ static void print_dataset_info(hid_t dcpl_id, else { char str[255], temp[20]; - strcpy(str,"dset "); - strcat(str,strfilter); + HDstrcpy(str,"dset "); + HDstrcat(str,strfilter); sprintf(temp," (%.3f:1)",ratio); - strcat(str,temp); + HDstrcat(str,temp); printf(FORMAT_OBJ,str,objname); } } diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index c7d8b1e..213ff65 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -44,13 +44,13 @@ int aux_find_obj(const char* name, /* object name from traverse list */ for ( i=0; i<options->op_tbl->nelems; i++) { - if (strcmp(options->op_tbl->objs[i].path,name)==0) + if (HDstrcmp(options->op_tbl->objs[i].path,name)==0) { *obj = options->op_tbl->objs[i]; return i; } - pdest = strstr(name,options->op_tbl->objs[i].path); + pdest = HDstrstr(name,options->op_tbl->objs[i].path); result = (int)(pdest - name); /* found at position 1, meaning without '/' */ diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index 7d2fc62..99d700d 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -13,10 +13,6 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - #include "h5tools_utils.h" #include "h5repack.h" @@ -124,7 +120,7 @@ int main(int argc, const char **argv) infile = argv[ opt_ind ]; outfile = argv[ opt_ind + 1 ]; - if ( strcmp( infile, outfile ) == 0 ) + if ( HDstrcmp( infile, outfile ) == 0 ) { error_msg("file names cannot be the same\n"); usage(h5tools_getprogname()); @@ -390,7 +386,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) int idx = 0; int ssize = 0; - char *msgPtr = strchr( opt_arg, ':'); + char *msgPtr = HDstrchr( opt_arg, ':'); options->latest = 1; /* must use latest format */ if (msgPtr == NULL) { @@ -401,22 +397,22 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) else { char msgType[10]; - strcpy(msgType, msgPtr+1); + HDstrcpy(msgType, msgPtr+1); msgPtr[0] = '\0'; ssize = atoi( opt_arg ); - if (strncmp(msgType, "dspace",6) == 0) { + if (HDstrncmp(msgType, "dspace",6) == 0) { options->msg_size[0] = ssize; } - else if (strncmp(msgType, "dtype", 5) == 0) { + else if (HDstrncmp(msgType, "dtype", 5) == 0) { options->msg_size[1] = ssize; } - else if (strncmp(msgType, "fill", 4) == 0) { + else if (HDstrncmp(msgType, "fill", 4) == 0) { options->msg_size[2] = ssize; } - else if (strncmp(msgType, "pline", 5) == 0) { + else if (HDstrncmp(msgType, "pline", 5) == 0) { options->msg_size[3] = ssize; } - else if (strncmp(msgType, "attr", 4) == 0) { + else if (HDstrncmp(msgType, "attr", 4) == 0) { options->msg_size[4] = ssize; } } @@ -454,14 +450,14 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) { char strategy[MAX_NC_NAME]; - strcpy(strategy, opt_arg); - if(!strcmp(strategy, "ALL_PERSIST")) + HDstrcpy(strategy, opt_arg); + if(!HDstrcmp(strategy, "ALL_PERSIST")) options->fs_strategy = H5F_FILE_SPACE_ALL_PERSIST; - else if(!strcmp(strategy, "ALL")) + else if(!HDstrcmp(strategy, "ALL")) options->fs_strategy = H5F_FILE_SPACE_ALL; - else if(!strcmp(strategy, "AGGR_VFD")) + else if(!HDstrcmp(strategy, "AGGR_VFD")) options->fs_strategy = H5F_FILE_SPACE_AGGR_VFD; - else if(!strcmp(strategy, "VFD")) + else if(!HDstrcmp(strategy, "VFD")) options->fs_strategy = H5F_FILE_SPACE_VFD; else { error_msg("invalid file space management strategy\n", opt_arg ); @@ -533,7 +529,7 @@ void read_info(const char *filename, * filter *------------------------------------------------------------------------- */ - if (strcmp(stype,"-f") == 0) { + if (HDstrcmp(stype,"-f") == 0) { /* find begining of info */ i=0; c='0'; @@ -563,7 +559,7 @@ void read_info(const char *filename, * layout *------------------------------------------------------------------------- */ - else if (strcmp(stype,"-l") == 0) { + else if (HDstrcmp(stype,"-l") == 0) { /* find begining of info */ i=0; c='0'; diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index 50f97bd..57b5fa7 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.c @@ -13,8 +13,6 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdlib.h> -#include <string.h> #include "h5repack.h" #include "h5tools_utils.h" @@ -32,7 +30,7 @@ void init_packobject(pack_info_t *obj) { int j, k; - strcpy(obj->path,"\0"); + HDstrcpy(obj->path,"\0"); for ( j=0; j<H5_REPACK_MAX_NFILTERS; j++) { obj->filter[j].filtn = -1; @@ -225,7 +223,7 @@ int options_add_layout( obj_list_t *obj_list, for (i = 0; i < table->nelems; i++) { /*already on the table */ - if (strcmp(obj_list[j].obj,table->objs[i].path)==0) + 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) @@ -248,7 +246,7 @@ int options_add_layout( obj_list_t *obj_list, /* keep the grow in a temp var */ I = table->nelems + added; added++; - strcpy(table->objs[I].path,obj_list[j].obj); + 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 @@ -256,12 +254,12 @@ int options_add_layout( obj_list_t *obj_list, -f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20 dset1 is already inserted, but dset2 must also be */ - else if (found==1 && strcmp(obj_list[j].obj,table->objs[i].path)!=0) + 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++; - strcpy(table->objs[I].path,obj_list[j].obj); + HDstrcpy(table->objs[I].path,obj_list[j].obj); aux_tblinsert_layout(table,I,pack); } } /* j */ @@ -275,7 +273,7 @@ int options_add_layout( obj_list_t *obj_list, { I = table->nelems + added; added++; - strcpy(table->objs[I].path,obj_list[j].obj); + HDstrcpy(table->objs[I].path,obj_list[j].obj); aux_tblinsert_layout(table,I,pack); } @@ -324,7 +322,7 @@ int options_add_filter(obj_list_t *obj_list, for (i = 0; i < table->nelems; i++) { /*already on the table */ - if (strcmp(obj_list[j].obj,table->objs[i].path)==0) + if (HDstrcmp(obj_list[j].obj,table->objs[i].path)==0) { /* insert */ aux_tblinsert_filter(table,i,filt); @@ -338,7 +336,7 @@ int options_add_filter(obj_list_t *obj_list, /* keep the grow in a temp var */ I = table->nelems + added; added++; - strcpy(table->objs[I].path,obj_list[j].obj); + 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 @@ -346,12 +344,12 @@ int options_add_filter(obj_list_t *obj_list, -l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1 dset1 is already inserted, but dset2 must also be */ - else if (found==1 && strcmp(obj_list[j].obj,table->objs[i].path)!=0) + 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++; - strcpy(table->objs[I].path,obj_list[j].obj); + HDstrcpy(table->objs[I].path,obj_list[j].obj); aux_tblinsert_filter(table,I,filt); } } /* j */ @@ -365,7 +363,7 @@ int options_add_filter(obj_list_t *obj_list, { I = table->nelems + added; added++; - strcpy(table->objs[I].path,obj_list[j].obj); + HDstrcpy(table->objs[I].path,obj_list[j].obj); aux_tblinsert_filter(table,I,filt); } } @@ -393,7 +391,7 @@ pack_info_t* options_get_object( const char *path, for ( i = 0; i < table->nelems; i++) { /* found it */ - if (strcmp(table->objs[i].path,path)==0) + if (HDstrcmp(table->objs[i].path,path)==0) { return (&table->objs[i]); } diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index d3a7419..d3c6014 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -13,11 +13,6 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <ctype.h> - #include "h5repack.h" #include "h5tools_utils.h" @@ -109,7 +104,7 @@ obj_list_t* parse_filter(const char *str, if ( c==',' || j==end_obj-1) { if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0'; - strcpy(obj_list[n].obj,sobj); + HDstrcpy(obj_list[n].obj,sobj); memset(sobj,0,sizeof(sobj)); n++; k=-1; @@ -143,7 +138,7 @@ obj_list_t* parse_filter(const char *str, * example SZIP=8,NN *------------------------------------------------------------------------- */ - if (strcmp(scomp,"SZIP")==0) + if (HDstrcmp(scomp,"SZIP")==0) { l=-1; /* mask index check */ for ( m=0,u=i+1; u<len; u++,m++) @@ -171,9 +166,9 @@ obj_list_t* parse_filter(const char *str, smask[l]='\0'; i=len-1; /* end */ (*n_objs)--; /* we counted an extra ',' */ - if (strcmp(smask,"NN")==0) + if (HDstrcmp(smask,"NN")==0) filt->cd_values[j++]=H5_SZIP_NN_OPTION_MASK; - else if (strcmp(smask,"EC")==0) + else if (HDstrcmp(smask,"EC")==0) filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK; else { @@ -203,7 +198,7 @@ obj_list_t* parse_filter(const char *str, *------------------------------------------------------------------------- */ - else if (strcmp(scomp,"SOFF")==0) + else if (HDstrcmp(scomp,"SOFF")==0) { l=-1; /* mask index check */ for ( m=0,u=i+1; u<len; u++,m++) @@ -231,9 +226,9 @@ obj_list_t* parse_filter(const char *str, smask[l]='\0'; i=len-1; /* end */ (*n_objs)--; /* we counted an extra ',' */ - if (strcmp(smask,"IN")==0) + if (HDstrcmp(smask,"IN")==0) filt->cd_values[j++]=H5Z_SO_INT; - else if (strcmp(smask,"DS")==H5Z_SO_FLOAT_DSCALE) + else if (HDstrcmp(smask,"DS")==H5Z_SO_FLOAT_DSCALE) filt->cd_values[j++]=H5Z_SO_FLOAT_DSCALE; else { @@ -290,7 +285,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_NONE *------------------------------------------------------------------------- */ - if (strcmp(scomp,"NONE")==0) + if (HDstrcmp(scomp,"NONE")==0) { filt->filtn=H5Z_FILTER_NONE; filt->cd_nelmts = 0; @@ -300,7 +295,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_DEFLATE *------------------------------------------------------------------------- */ - else if (strcmp(scomp,"GZIP")==0) + else if (HDstrcmp(scomp,"GZIP")==0) { filt->filtn=H5Z_FILTER_DEFLATE; filt->cd_nelmts = 1; @@ -316,7 +311,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_SZIP *------------------------------------------------------------------------- */ - else if (strcmp(scomp,"SZIP")==0) + else if (HDstrcmp(scomp,"SZIP")==0) { filt->filtn=H5Z_FILTER_SZIP; filt->cd_nelmts = 2; @@ -332,7 +327,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_SHUFFLE *------------------------------------------------------------------------- */ - else if (strcmp(scomp,"SHUF")==0) + else if (HDstrcmp(scomp,"SHUF")==0) { filt->filtn=H5Z_FILTER_SHUFFLE; filt->cd_nelmts = 0; @@ -347,7 +342,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_FLETCHER32 *------------------------------------------------------------------------- */ - else if (strcmp(scomp,"FLET")==0) + else if (HDstrcmp(scomp,"FLET")==0) { filt->filtn=H5Z_FILTER_FLETCHER32; filt->cd_nelmts = 0; @@ -362,7 +357,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_NBIT *------------------------------------------------------------------------- */ - else if (strcmp(scomp,"NBIT")==0) + else if (HDstrcmp(scomp,"NBIT")==0) { filt->filtn=H5Z_FILTER_NBIT; filt->cd_nelmts = 0; @@ -377,7 +372,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_SCALEOFFSET *------------------------------------------------------------------------- */ - else if (strcmp(scomp,"SOFF")==0) + else if (HDstrcmp(scomp,"SOFF")==0) { filt->filtn=H5Z_FILTER_SCALEOFFSET; filt->cd_nelmts = 2; @@ -437,7 +432,7 @@ obj_list_t* parse_filter(const char *str, error_msg("pixels_per_block is too large in <%s>\n",str); exit(EXIT_FAILURE); } - if ( (strcmp(smask,"NN")!=0) && (strcmp(smask,"EC")!=0) ) + if ( (HDstrcmp(smask,"NN")!=0) && (HDstrcmp(smask,"EC")!=0) ) { if (obj_list) free(obj_list); error_msg("szip mask must be 'NN' or 'EC' \n"); @@ -530,7 +525,7 @@ obj_list_t* parse_layout(const char *str, if ( c==',' || j==end_obj-1) { if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0'; - strcpy(obj_list[n].obj,sobj); + HDstrcpy(obj_list[n].obj,sobj); memset(sobj,0,sizeof(sobj)); n++; k=-1; @@ -551,11 +546,11 @@ obj_list_t* parse_layout(const char *str, if (n==5) { slayout[n]='\0'; /*cut string */ - if (strcmp(slayout,"COMPA")==0) + if (HDstrcmp(slayout,"COMPA")==0) pack->layout=H5D_COMPACT; - else if (strcmp(slayout,"CONTI")==0) + else if (HDstrcmp(slayout,"CONTI")==0) pack->layout=H5D_CONTIGUOUS; - else if (strcmp(slayout,"CHUNK")==0) + else if (HDstrcmp(slayout,"CHUNK")==0) pack->layout=H5D_CHUNKED; else { error_msg("in parse layout, not a valid layout in <%s>\n",str); @@ -618,7 +613,7 @@ obj_list_t* parse_layout(const char *str, else if (i==len-1) { /*no more parameters */ sdim[k]='\0'; k=0; - if (strcmp(sdim,"NONE")==0) + if (HDstrcmp(sdim,"NONE")==0) { pack->chunk.rank=-2; } diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index aa2e823..091133e 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -14,12 +14,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include <stdlib.h> -#include <string.h> -#include <stdio.h> #include "h5repack.h" -#include "H5private.h" #include "h5diff.h" #include "h5tools.h" |