From 9bc89569d6990a1ebbe8fa595a23d5df59575c7f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 13 Oct 2003 14:21:41 -0500 Subject: [svn-r7611] Purpose: Code cleanup Description: Cleaned up various compiler warnings Platforms tested: FreeBSD 4.9 (sleipnir) Linux 2.4 (verbena) w/FORTRAN too minor for h5committest --- fortran/src/H5Af.c | 2 +- fortran/src/H5Df.c | 96 +++++++++++++++++++++++++------------------------- fortran/src/H5If.c | 2 +- fortran/src/H5Pf.c | 38 ++++++++++---------- fortran/src/H5Sf.c | 7 ++-- fortran/src/H5Tf.c | 22 ++++++------ fortran/src/H5f90kit.c | 4 +-- fortran/test/t.c | 4 +-- 8 files changed, 88 insertions(+), 87 deletions(-) diff --git a/fortran/src/H5Af.c b/fortran/src/H5Af.c index 7bba6d7..696b8ed 100644 --- a/fortran/src/H5Af.c +++ b/fortran/src/H5Af.c @@ -571,7 +571,7 @@ nh5aget_name_c(hid_t_f *attr_id, size_t_f *bufsize, _fcd buf) * Allocate buffer to hold name of an attribute */ c_bufsize = *bufsize; - c_buf = (char *)HDmalloc((int)c_bufsize +1); + c_buf = (char *)HDmalloc(c_bufsize +1); if (c_buf == NULL) return ret_value; /* diff --git a/fortran/src/H5Df.c b/fortran/src/H5Df.c index 04b38b2..22ce62c 100644 --- a/fortran/src/H5Df.c +++ b/fortran/src/H5Df.c @@ -741,23 +741,23 @@ nh5dread_ref_obj_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space /* * Allocate temporary buffer. */ - buf_c = (hobj_ref_t*)HDmalloc(sizeof(hobj_ref_t)*(n)); + buf_c = (hobj_ref_t*)HDmalloc(sizeof(hobj_ref_t)*(size_t)n); if ( buf_c != NULL ) { - /* - * Call H5Dread function. - */ - c_dset_id = (hid_t)*dset_id; - c_mem_type_id = (hid_t)*mem_type_id; - c_mem_space_id = (hid_t)*mem_space_id; - c_file_space_id = (hid_t)*file_space_id; - ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); - if (ret >=0) { - for (i = 0; i < n; i++) { - HDmemcpy(buf, &buf_c[i], H5R_OBJ_REF_BUF_SIZE); - buf = buf + REF_OBJ_BUF_LEN_F; - } - } - if ( buf_c != NULL ) HDfree(buf_c); + /* + * Call H5Dread function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); + if (ret >=0) { + for (i = 0; i < n; i++) { + HDmemcpy(buf, &buf_c[i], H5R_OBJ_REF_BUF_SIZE); + buf = buf + REF_OBJ_BUF_LEN_F; + } + } + if ( buf_c != NULL ) HDfree(buf_c); } if (ret < 0) return ret_value; ret_value = 0; @@ -859,23 +859,23 @@ nh5dread_ref_reg_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space /* * Allocate temporary buffer. */ - buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t)*(n)); + buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t)*(size_t)n); if ( buf_c != NULL ) { - /* - * Call H5Dread function. - */ - c_dset_id = (hid_t)*dset_id; - c_mem_type_id = (hid_t)*mem_type_id; - c_mem_space_id = (hid_t)*mem_space_id; - c_file_space_id = (hid_t)*file_space_id; - ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); - if (ret >=0) { - for (i = 0; i < n; i++) { - HDmemcpy(buf, buf_c[i].heapid, H5R_DSET_REG_REF_BUF_SIZE); - buf = buf + REF_REG_BUF_LEN_F; - } - } - if ( buf_c != NULL ) HDfree(buf_c); + /* + * Call H5Dread function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); + if (ret >=0) { + for (i = 0; i < n; i++) { + HDmemcpy(buf, buf_c[i].heapid, H5R_DSET_REG_REF_BUF_SIZE); + buf = buf + REF_REG_BUF_LEN_F; + } + } + if ( buf_c != NULL ) HDfree(buf_c); } if (ret < 0) return ret_value; ret_value = 0; @@ -1093,7 +1093,7 @@ nh5dvlen_get_max_len_c ( hid_t_f *dset_id , hid_t_f *type_id, hid_t_f *space_id num_elem = H5Sget_select_npoints(c_space_id); if( num_elem < 0) return ret_value; - c_buf = (hvl_t *)malloc(sizeof(hvl_t)*num_elem); + c_buf = (hvl_t *)malloc(sizeof(hvl_t)*(size_t)num_elem); if (c_buf == NULL) return ret_value; status = H5Dread(c_dset_id, c_type_id, H5S_ALL, c_space_id, H5P_DEFAULT, c_buf); if(status < 0) goto DONE; @@ -1142,7 +1142,7 @@ nh5dwrite_vl_integer_c ( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_ size_t max_len; hvl_t *c_buf; - int i; + hsize_t i; hsize_t num_elem; max_len = (size_t)dims[0]; @@ -1154,7 +1154,7 @@ nh5dwrite_vl_integer_c ( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_ c_file_space_id = (hid_t)*file_space_id; c_xfer_prp = (hid_t)*xfer_prp; - c_buf = (hvl_t *)malloc(num_elem * sizeof(hvl_t)); + c_buf = (hvl_t *)malloc((size_t)num_elem * sizeof(hvl_t)); if (c_buf == NULL) return ret_value; tmp = (int *)buf; for (i=0; i < num_elem; i++) { @@ -1219,7 +1219,7 @@ nh5dread_vl_integer_c ( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_s num_elem = H5Sget_select_npoints(c_mem_space_id); if(num_elem != dims[1]) return ret_value; - c_buf = (hvl_t *)malloc(num_elem * sizeof(hvl_t)); + c_buf = (hvl_t *)malloc((size_t)num_elem * sizeof(hvl_t)); if (c_buf == NULL) return ret_value; /* * Call H5Dread function. @@ -1269,7 +1269,7 @@ nh5dwrite_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_sp size_t max_len; char **c_buf; - int i; + hsize_t i; hsize_t num_elem; max_len = (size_t)dims[0]; @@ -1284,11 +1284,11 @@ nh5dwrite_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_sp /* * Allocate arra of character pointers */ - c_buf = (char **)malloc(num_elem * sizeof(char *)); + c_buf = (char **)malloc((size_t)num_elem * sizeof(char *)); if (c_buf == NULL) return ret_value; /* Copy data to long C string */ - tmp = (char *)HD5f2cstring(buf, max_len*num_elem); + tmp = (char *)HD5f2cstring(buf, (int)(max_len*num_elem)); if (tmp == NULL) { free(c_buf); return ret_value; } @@ -1297,8 +1297,8 @@ nh5dwrite_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_sp */ tmp_p = tmp; for (i=0; i < num_elem; i++) { - c_buf[i] = (char *) malloc(len[i]+1); - memcpy(c_buf[i], tmp_p, len[i]); + c_buf[i] = (char *) malloc((size_t)len[i]+1); + memcpy(c_buf[i], tmp_p, (size_t)len[i]); c_buf[i][len[i]] = '\0'; tmp_p = tmp_p + max_len; } @@ -1348,7 +1348,7 @@ nh5dread_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_spa size_t max_len; char **c_buf; - int i; + hsize_t i; hsize_t num_elem; max_len = (size_t)dims[0]; @@ -1363,7 +1363,7 @@ nh5dread_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_spa /* * Allocate array of character pointers */ - c_buf = (char **)malloc(num_elem * sizeof(char *)); + c_buf = (char **)malloc((size_t)num_elem * sizeof(char *)); if (c_buf == NULL) return ret_value; /* @@ -1374,7 +1374,7 @@ nh5dread_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_spa return ret_value; } /* Copy data to long C string */ - tmp = (char *)malloc(max_len*num_elem +1); + tmp = (char *)malloc((size_t)(max_len*num_elem) +1); tmp_p = tmp; for (i=0; i=0 && !isgraph((int)str[i]); i--) /*EMPTY*/; - cstr = (char *) HDmalloc( (i + 2)); + cstr = (char *) HDmalloc( (size_t)(i + 2)); if (cstr == NULL) return NULL; cstr[i + 1] = '\0'; - HDmemcpy(cstr,str,i+1); + HDmemcpy(cstr,str,(size_t)(i+1)); return cstr; } /* HD5f2cstring */ diff --git a/fortran/test/t.c b/fortran/test/t.c index 4f19ea4..3109523 100644 --- a/fortran/test/t.c +++ b/fortran/test/t.c @@ -46,13 +46,13 @@ nh5_fixname_c(_fcd base_name, int_f *base_namelen, hid_t_f* fapl, _fcd full_name c_base_namelen = *base_namelen; c_base_name = (char *)HD5f2cstring(base_name, c_base_namelen); if (c_base_name == NULL) goto DONE; - c_full_name = (char *) HDmalloc(*full_namelen + 1); + c_full_name = (char *) HDmalloc((size_t)*full_namelen + 1); if (c_full_name == NULL) goto DONE; /* * Call h5_fixname function. */ - if (NULL != h5_fixname(c_base_name, c_fapl, c_full_name, *full_namelen + 1)) { + if (NULL != h5_fixname(c_base_name, c_fapl, c_full_name, (size_t)*full_namelen + 1)) { HD5packFstring(c_full_name, _fcdtocp(full_name), *full_namelen); ret_value = 0; goto DONE; -- cgit v0.12