summaryrefslogtreecommitdiffstats
path: root/tools/h5copy
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2013-03-20 03:44:28 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2013-03-20 03:44:28 (GMT)
commit59dd5665a5887efa8e91e0339719e4bd0c2be2a6 (patch)
treef00ce45d9f64ae1c06d043947fb6d65900160d26 /tools/h5copy
parent8ad18f496ad665faffc4f2fd0eae8140b53ab760 (diff)
downloadhdf5-59dd5665a5887efa8e91e0339719e4bd0c2be2a6.zip
hdf5-59dd5665a5887efa8e91e0339719e4bd0c2be2a6.tar.gz
hdf5-59dd5665a5887efa8e91e0339719e4bd0c2be2a6.tar.bz2
[svn-r23395] Description:
Bring Coverity changes from branch to trunk: r20682: fixed coverity: 76, 77, 635, 636, 1164, 1165, 1166, 1121, 1122, 1117, 1343 Tested on: Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN (too minor to require h5committest)
Diffstat (limited to 'tools/h5copy')
-rw-r--r--tools/h5copy/h5copy.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index 574ba94..b2ad9d0 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -199,23 +199,21 @@ static int parse_flag(const char* str_flag, unsigned *flag)
int
main (int argc, const char *argv[])
{
- hid_t fid_src=-1;
- hid_t fid_dst=-1;
- char *fname_src=NULL;
- char *fname_dst=NULL;
- char *oname_src=NULL;
- char *oname_dst=NULL;
- unsigned flag=0;
- unsigned verbose=0;
- unsigned parents=0;
+ hid_t fid_src = -1;
+ hid_t fid_dst = -1;
+ char *fname_src = NULL;
+ char *fname_dst = NULL;
+ char *oname_src = NULL;
+ char *oname_dst = NULL;
+ char *str_flag = NULL;
+ unsigned flag = 0;
+ unsigned verbose = 0;
+ unsigned parents = 0;
hid_t ocpl_id = (-1); /* Object copy property list */
hid_t lcpl_id = (-1); /* Link creation property list */
- char str_flag[20];
int opt;
int li_ret;
h5tool_link_info_t linkinfo;
- int i, len;
- char *str_ptr=NULL;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -249,7 +247,7 @@ main (int argc, const char *argv[])
usage();
leave(EXIT_FAILURE);
}
- HDstrcpy(str_flag,opt_arg);
+ str_flag = HDstrdup(opt_arg);
break;
case 'h':
@@ -377,8 +375,10 @@ main (int argc, const char *argv[])
{
printf("Copying file <%s> and object <%s> to file <%s> and object <%s>\n",
fname_src, oname_src, fname_dst, oname_dst);
- if (flag)
+ if (flag) {
+ HDassert(str_flag);
printf("Using %s flag\n", str_flag);
+ }
}
@@ -417,14 +417,19 @@ main (int argc, const char *argv[])
} /* end if */
else /* error, if parent groups doesn't already exist in destination file */
{
+ size_t i, len;
+
len = HDstrlen(oname_dst);
+
/* check if all the parents groups exist. skip root group */
for (i = 1; i < len; i++)
{
if ('/'==oname_dst[i])
{
- str_ptr = (char*)HDcalloc((size_t)i+1, sizeof(char));
- HDstrncpy (str_ptr, oname_dst, (size_t)i);
+ char *str_ptr;
+
+ str_ptr = (char *)HDcalloc(i + 1, sizeof(char));
+ HDstrncpy(str_ptr, oname_dst, i);
str_ptr[i]='\0';
if (H5Lexists(fid_dst, str_ptr, H5P_DEFAULT) <= 0)
{
@@ -513,6 +518,8 @@ error:
HDfree(oname_dst);
if (oname_src)
HDfree(oname_src);
+ if (str_flag)
+ HDfree(str_flag);
h5tools_close();