summaryrefslogtreecommitdiffstats
path: root/test/dt_arith.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-01-15 03:05:59 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-01-15 03:05:59 (GMT)
commit066294e32131d1d81d326d35d67b0d753e8b8b56 (patch)
treeff8ac3f4d94edceeacf167486a8a9f7adcd01d63 /test/dt_arith.c
parent22da4232a4693e3f0a4ee2f37053f85a28e885fd (diff)
downloadhdf5-066294e32131d1d81d326d35d67b0d753e8b8b56.zip
hdf5-066294e32131d1d81d326d35d67b0d753e8b8b56.tar.gz
hdf5-066294e32131d1d81d326d35d67b0d753e8b8b56.tar.bz2
[svn-r18109] Description:
Bring r18076-18096 from hdf5_1_8_coverity branch to trunk: r18076: Correct Coverity issue #1 by removing dead code r18077: Fix coverity item 142. When an error occurred while copying a linked list in H5S_point_copy, the library would not free the partially allocated list. Added code to free the list in this case. r18078: Correct Coverity issue #2 by removing impossible to reach code. r18079: Correct #3 by removing impossible to reach code. r18080: Correct Coverity issue #4 by removing impossible to reach code. r18081: fix coverity 26 , check (dblik->parent) before calls H5HF_man_iblock_detach(). r18082: Fixed coverity issues 321 and 316. 321: freed sm_buf in error handling to remove resource leak. Also set sm_buf to NULL after other instances in which it is freed to prevent double free. 316: initialized nmembs to 0. r18083: Correct Coverity issue #6 by removing debugging knob from error reporting code. r18084: Fix coverity item 269 + others. When a error occurred in a function using the h5tools error framework, the "past_catch" variable would not be set to true because that statement was before the label that goto jumped to. This could cause a failure in the cleanup section to go back to the start of the section, freeing variables twice, etc. Moved the label infront of past_catch=TRUE. r18085: fixed coverity #27, check if (heap) before use heap->obj.... r18086: fixed coverity #28, check curr_span not null before use it at if(curr_span && (io_bytes_left==0 || curr_seq>=maxseq)) r18087: Correct Coverity issue #7 by cleaning up correctly on error r18088: Correct Coverity #8 by removing unchanged variable checking code. r18089: Correct Coverity issue #9 - remove impossible to reach code. r18090: Correct Coverity issue #11 by removing impossible to reach code. Also clean up some minor style issues. r18091: Fix coverity items 314 and 318. Changed the improper assertion of the return value of a library function to a check, and a return(void) on failure. r18092: Fix coverity item 70. Changed the improper assertion of the return value of a library function to a check, and a return(void) on failure. r18093: Correct Coverity issue #12 by removing dead code. r18094: Correct Coverity issue #16 by removing debugging code. r18095: Fixed coverity issue # 271. Removed redundant checking and freeing of sm_buf1 and sm_buf2. r18096: Correct Coverity issue #17 by refactoring test to remove dead code. Also, removed previous "coverity" statements in comments, we'll review those issues again and see if we can figure them out, now that we have more experience with Coverity. Tested on: Mac OS X/32 10.6.2 (amazon)
Diffstat (limited to 'test/dt_arith.c')
-rw-r--r--test/dt_arith.c229
1 files changed, 107 insertions, 122 deletions
diff --git a/test/dt_arith.c b/test/dt_arith.c
index 420570a..13cf5ba 100644
--- a/test/dt_arith.c
+++ b/test/dt_arith.c
@@ -5001,192 +5001,177 @@ run_int_fp_conv(const char *name)
static int
run_fp_int_conv(const char *name)
{
+#ifdef H5_FP_TO_INTEGER_OVERFLOW_WORKS
int nerrors = 0;
int test_values;
- int i;
- int run_test = TRUE;
-#ifndef H5_FP_TO_INTEGER_OVERFLOW_WORKS
- /* For Cray X1, the compiler generates floating exception when the
- * conversion overflows. So disable all of the conversions from
- * floating-point numbers to integers.
- */
- run_test = FALSE;
-#endif
-
-#ifdef H5_VMS
- run_test = TRUE;
-#endif
-
- if(run_test) {
#ifdef H5_VMS
- test_values = TEST_NORMAL;
- {
+ test_values = TEST_NORMAL;
#else
- for(i=0; i<3; i++) {
- if(i==0)
- test_values = TEST_NORMAL;
- else if(i==1)
- test_values = TEST_DENORM;
- else
- test_values = TEST_SPECIAL;
+ for(test_values = TEST_NORMAL; test_values <= TEST_SPECIAL; test_values++) {
#endif /*H5_VMS*/
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SCHAR);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SCHAR);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UCHAR);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UCHAR);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UCHAR);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UCHAR);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SHORT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SHORT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SHORT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SHORT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_USHORT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_USHORT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_USHORT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_USHORT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_INT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_INT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_INT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_INT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UINT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UINT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UINT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UINT);
#if H5_SIZEOF_LONG!=H5_SIZEOF_INT
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LONG);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LONG);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULONG);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULONG);
#endif
#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
- if(!strcmp(name, "hw")) { /* Hardware conversion */
- /* Windows .NET 2003 doesn't work for hardware conversion of this case.
- * .NET should define this macro H5_HW_FP_TO_LLONG_NOT_WORKS. */
+ if(!strcmp(name, "hw")) { /* Hardware conversion */
+ /* Windows .NET 2003 doesn't work for hardware conversion of this case.
+ * .NET should define this macro H5_HW_FP_TO_LLONG_NOT_WORKS. */
#ifndef H5_HW_FP_TO_LLONG_NOT_WORKS
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG);
#endif /*H5_HW_FP_TO_LLONG_NOT_WORKS*/
- } else { /* Software conversion */
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG);
- }
+ } else { /* Software conversion */
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG);
+ }
#ifdef H5_FP_TO_ULLONG_RIGHT_MAXIMUM
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULLONG);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULLONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULLONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULLONG);
#else /*H5_FP_TO_ULLONG_RIGHT_MAXIMUM*/
- {
- char str[256]; /*hello string */
-
- sprintf(str, "Testing %s %s -> %s conversions",
- name, "float", "unsigned long long");
- printf("%-70s", str);
- SKIPPED();
- HDputs(" Test skipped due to hardware conversion error.");
-
- sprintf(str, "Testing %s %s -> %s conversions",
- name, "double", "unsigned long long");
- printf("%-70s", str);
- SKIPPED();
- HDputs(" Test skipped due to hardware conversion error.");
- }
+ {
+ char str[256]; /*hello string */
+
+ sprintf(str, "Testing %s %s -> %s conversions",
+ name, "float", "unsigned long long");
+ printf("%-70s", str);
+ SKIPPED();
+ HDputs(" Test skipped due to hardware conversion error.");
+
+ sprintf(str, "Testing %s %s -> %s conversions",
+ name, "double", "unsigned long long");
+ printf("%-70s", str);
+ SKIPPED();
+ HDputs(" Test skipped due to hardware conversion error.");
+ }
#endif /*H5_FP_TO_ULLONG_RIGHT_MAXIMUM*/
#endif
#if H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_INTEGER_ACCURATE
#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UCHAR);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_INT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UCHAR);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_INT);
#if H5_LDOUBLE_TO_UINT_ACCURATE
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT);
#else /*H5_LDOUBLE_TO_UINT_ACCURATE*/
- {
- char str[256]; /*string */
+ {
+ char str[256]; /*string */
- sprintf(str, "Testing %s %s -> %s conversions",
- name, "long double", "unsigned int");
- printf("%-70s", str);
- SKIPPED();
+ sprintf(str, "Testing %s %s -> %s conversions",
+ name, "long double", "unsigned int");
+ printf("%-70s", str);
+ SKIPPED();
#if H5_SIZEOF_LONG_DOUBLE!=0
- HDputs(" Test skipped due to hardware conversion error.");
+ HDputs(" Test skipped due to hardware conversion error.");
#else
- HDputs(" Test skipped due to disabled long double.");
+ HDputs(" Test skipped due to disabled long double.");
#endif
- }
+ }
#endif /*H5_LDOUBLE_TO_UINT_ACCURATE*/
#if H5_SIZEOF_LONG!=H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE!=0
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG);
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULONG);
#endif
#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG && H5_SIZEOF_LONG_DOUBLE!=0
#ifdef H5_LDOUBLE_TO_LLONG_ACCURATE
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LLONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LLONG);
#else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/
- {
- char str[256]; /*string */
+ {
+ char str[256]; /*string */
- sprintf(str, "Testing %s %s -> %s conversions",
- name, "long double", "long long");
- printf("%-70s", str);
- SKIPPED();
+ sprintf(str, "Testing %s %s -> %s conversions",
+ name, "long double", "long long");
+ printf("%-70s", str);
+ SKIPPED();
#if H5_SIZEOF_LONG_DOUBLE!=0
- HDputs(" Test skipped due to hardware conversion error.");
+ HDputs(" Test skipped due to hardware conversion error.");
#else
- HDputs(" Test skipped due to disabled long double.");
+ HDputs(" Test skipped due to disabled long double.");
#endif
- }
+ }
#endif /*H5_LDOUBLE_TO_LLONG_ACCURATE*/
#if defined(H5_FP_TO_ULLONG_RIGHT_MAXIMUM) && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)
- nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULLONG);
+ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULLONG);
#else /*H5_FP_TO_ULLONG_RIGHT_MAXIMUM && H5_LDOUBLE_TO_LLONG_ACCURATE*/
- {
- char str[256]; /*string */
+ {
+ char str[256]; /*string */
- sprintf(str, "Testing %s %s -> %s conversions",
- name, "long double", "unsigned long long");
- printf("%-70s", str);
- SKIPPED();
+ sprintf(str, "Testing %s %s -> %s conversions",
+ name, "long double", "unsigned long long");
+ printf("%-70s", str);
+ SKIPPED();
#if H5_SIZEOF_LONG_DOUBLE!=0
- HDputs(" Test skipped due to hardware conversion error.");
+ HDputs(" Test skipped due to hardware conversion error.");
#else
- HDputs(" Test skipped due to disabled long double.");
+ HDputs(" Test skipped due to disabled long double.");
#endif
- }
+ }
#endif /*H5_FP_TO_ULLONG_RIGHT_MAXIMUM && H5_LDOUBLE_TO_LLONG_ACCURATE*/
#endif
#endif
#else /*H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_INTEGER_ACCURATE*/
- {
- char str[256]; /*hello string */
+ {
+ char str[256]; /*hello string */
- sprintf(str, "Testing %s %s -> %s conversions",
- name, "long double", "all integers");
- printf("%-70s", str);
- SKIPPED();
+ sprintf(str, "Testing %s %s -> %s conversions",
+ name, "long double", "all integers");
+ printf("%-70s", str);
+ SKIPPED();
#if H5_SIZEOF_LONG_DOUBLE!=0
- HDputs(" Test skipped due to hardware conversion error.");
+ HDputs(" Test skipped due to hardware conversion error.");
#else
- HDputs(" Test skipped due to disabled long double.");
+ HDputs(" Test skipped due to disabled long double.");
#endif
- }
-#endif /*H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_INTEGER_ACCURATE*/
}
- } else {
- char str[256]; /*string */
+#endif /*H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_INTEGER_ACCURATE*/
+#ifndef H5_VMS
+ } /* end for */
+#endif /* H5_VMS */
+#else /* H5_FP_TO_INTEGER_OVERFLOW_WORKS */
+/* For Cray X1, the compiler generates floating exception when the
+ * conversion overflows. So disable all of the conversions from
+ * floating-point numbers to integers.
+ */
+ char str[256]; /*string */
- sprintf(str, "Testing %s %s -> %s conversions",
- name, "all floating-point numbers", "all integers");
- printf("%-70s", str);
- SKIPPED();
+ sprintf(str, "Testing %s %s -> %s conversions",
+ name, "all floating-point numbers", "all integers");
+ printf("%-70s", str);
+ SKIPPED();
#if H5_SIZEOF_LONG_DOUBLE!=0
- HDputs(" Test skipped due to hardware conversion error.");
+ HDputs(" Test skipped due to hardware conversion error.");
#else
- HDputs(" Test skipped due to disbaled long double.");
+ HDputs(" Test skipped due to disbaled long double.");
#endif
- }
+#endif /* H5_FP_TO_INTEGER_OVERFLOW_WORKS */
return nerrors;
}