summaryrefslogtreecommitdiffstats
path: root/tools/misc/talign.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2011-04-17 18:57:07 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2011-04-17 18:57:07 (GMT)
commit9431c7a97e5f44b91d557b0e9693fc110a2578dc (patch)
tree23f4162b68d45daffee0466caaa4a888c449df04 /tools/misc/talign.c
parent2898c115902975fa9e0cb4634a6b65598d24b445 (diff)
downloadhdf5-9431c7a97e5f44b91d557b0e9693fc110a2578dc.zip
hdf5-9431c7a97e5f44b91d557b0e9693fc110a2578dc.tar.gz
hdf5-9431c7a97e5f44b91d557b0e9693fc110a2578dc.tar.bz2
[svn-r20536] Description:
Clean up various warnings & code formatting issues. Bring changes from Coverity branch to trunk: r20085: Purpose: Fix coverity issue 793 Description: Modified H5S_hyper_project_simple_higher() to free the entire span list in new_space on failure. r20091: This is a fix for coverity bug #1683. Changed the two printfs to use %lu (unsigned long) for printing "dset_size". r20162: Purpose: Fix coverity issue 785 Description: Modified H5T_enum_nameof() to free "name" on failure if it was allocated. Also clarified some code in H5S_hyper_rebuild_helper(). r20189: Addressed coverity defect 783. H5SL_new_node() in H5SL.c was failing to free space allocated in its first alloc if the second alloc failed. Added a call to H5FL_FREE to address this issue. This is purely to keep coverity happy -- if this code is ever triggered, we have much larger problems. Note that this fix will trigger an unused return value complaint from coverity next week. r20190: Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call. r20191: Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN). r20232: Addressed coverity issues 923-925. Replaced calls to sprintf with calls to HDsnprintf. r20233: Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c. r20234: Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c. r20271: Purpose: Fix coverity issue 784 Description: Modified H5_debug_mask() to keep a list of files opened for use as a debugging output stream, and modified H5_term_library to close these files on exit. r20272: addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing code was safe, but modified to use strncpy() to keep coverity happy. r20273: Addresed coverity issues 1388 and 1389. Initialized sel_iter->type to NULL in H5S_select_iter_init. r20275: Purpose: Fix valgrind issue in mf.c Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so the retrieved node gets freed. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Diffstat (limited to 'tools/misc/talign.c')
-rw-r--r--tools/misc/talign.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/tools/misc/talign.c b/tools/misc/talign.c
index 24420bf..88ebaa6 100644
--- a/tools/misc/talign.c
+++ b/tools/misc/talign.c
@@ -50,10 +50,10 @@ int main(void)
float fnok[2] = {5678., 6785.};
float *fptr;
- char *data;
- char *mname;
+ char *data = NULL;
int result = 0;
+ herr_t error = 1;
printf("%-70s", "Testing alignment in compound datatypes");
@@ -67,7 +67,7 @@ int main(void)
}
H5E_BEGIN_TRY {
- H5Ldelete(fil, setname, H5P_DEFAULT);
+ (void)H5Ldelete(fil, setname, H5P_DEFAULT);
} H5E_END_TRY;
cs6 = H5Tcopy(H5T_C_S1);
@@ -87,7 +87,7 @@ int main(void)
H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt);
H5Tclose(array_dt);
- fix=h5tools_get_native_type(cmp);
+ fix = h5tools_get_native_type(cmp);
cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok));
@@ -107,7 +107,8 @@ int main(void)
H5Tclose(array_dt);
plist = H5Pcreate(H5P_DATASET_XFER);
- H5Pset_preserve(plist, 1);
+ if((error = H5Pset_preserve(plist, 1)) < 0)
+ goto out;
/*
* Create a small dataset, and write data into it we write each field
@@ -136,25 +137,36 @@ int main(void)
H5Dread(set, fix, spc, H5S_ALL, H5P_DEFAULT, data);
fptr = (float *)(data + H5Tget_member_offset(fix, 1));
- if(fok[0] != fptr[0] || fok[1] != fptr[1]
+out:
+ if(error < 0) {
+ result = 1;
+ puts("*FAILED - HDF5 library error*");
+ } else if(fok[0] != fptr[0] || fok[1] != fptr[1]
|| fnok[0] != fptr[2] || fnok[1] != fptr[3]) {
+ char *mname;
+
result = 1;
+ mname = H5Tget_member_name(fix, 0);
printf("%14s (%2d) %6s = %s\n",
- mname = H5Tget_member_name(fix, 0), (int)H5Tget_member_offset(fix,0),
+ mname, (int)H5Tget_member_offset(fix,0),
string5, (char *)(data + H5Tget_member_offset(fix, 0)));
free(mname);
+
fptr = (float *)(data + H5Tget_member_offset(fix, 1));
+ mname = H5Tget_member_name(fix, 1);
printf("Data comparison:\n"
"%14s (%2d) %6f = %f\n"
" %6f = %f\n",
- mname = H5Tget_member_name(fix, 1), (int)H5Tget_member_offset(fix,1),
+ mname, (int)H5Tget_member_offset(fix,1),
fok[0], fptr[0],
fok[1], fptr[1]);
free(mname);
+
fptr = (float *)(data + H5Tget_member_offset(fix, 2));
+ mname = H5Tget_member_name(fix, 2);
printf("%14s (%2d) %6f = %f\n"
" %6f = %6f\n",
- mname = H5Tget_member_name(fix, 2), (int)H5Tget_member_offset(fix,2),
+ mname, (int)H5Tget_member_offset(fix,2),
fnok[0], fptr[0],
fnok[1], fptr[1]);
free(mname);
@@ -170,12 +182,13 @@ int main(void)
fok[1], fptr[1],
fnok[0], fptr[2],
fnok[1], fptr[3]);
- puts("*FAILED*");
+ puts("*FAILED - compound type alignmnent problem*");
} else {
puts(" PASSED");
}
- free(data);
+ if(data)
+ free(data);
H5Sclose(spc);
H5Tclose(cmp);
H5Tclose(cmp1);