summaryrefslogtreecommitdiffstats
path: root/tools/lib
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 /tools/lib
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 'tools/lib')
-rw-r--r--tools/lib/h5diff_dset.c5
-rw-r--r--tools/lib/h5tools.c11
-rw-r--r--tools/lib/h5tools_error.h2
3 files changed, 8 insertions, 10 deletions
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index ad9331d..2cc84ca 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -545,11 +545,6 @@ hsize_t diff_datasetid( hid_t did1,
} /* elmtno */
H5Sclose(sm_space);
- /* free */
- HDfree(sm_buf1);
- sm_buf1 = NULL;
- HDfree(sm_buf2);
- sm_buf2 = NULL;
} /* hyperslab read */
}/*can_compare*/
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 8263909..7f1019a 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -2070,6 +2070,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
if(sm_buf)
HDfree(sm_buf);
+ sm_buf = NULL;
}
else
H5E_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print");
@@ -2081,6 +2082,9 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
} /* hyperslab_count loop */
CATCH
+ if(sm_buf)
+ HDfree(sm_buf);
+
return ret_value;
}
@@ -3285,7 +3289,7 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type)
char **name = NULL; /*member names */
unsigned char *value = NULL; /*value array */
unsigned char *copy = NULL; /*a pointer to value array */
- unsigned nmembs; /*number of members */
+ unsigned nmembs = 0; /*number of members */
int nchars; /*number of output characters */
hid_t super = -1; /*enum base integer type */
hid_t native = -1; /*native integer datatype */
@@ -3379,10 +3383,9 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type)
}
CATCH
-
if(name) {
/* Release resources */
- for (i = 0; i < nmembs; i++)
+ for(i = 0; i < nmembs; i++)
if(name[i])
free(name[i]);
free(name);
@@ -3394,7 +3397,7 @@ CATCH
if(super >= 0 && H5Tclose(super) < 0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class");
- if (0 == nmembs)
+ if(0 == nmembs)
h5tools_str_append(buffer, "\n<empty>");
return ret_value;
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index da8f03c..dc5f87b 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -71,7 +71,7 @@ extern hid_t H5E_tools_min_id_g;
/* Macro for "catching" flow of control when an error occurs. Note that the
* H5_LEAVE macro won't jump back here once it's past this point.
*/
-#define CATCH past_catch = TRUE; catch_except:;
+#define CATCH catch_except:; past_catch = TRUE;
/*
* H5_LEAVE macro, used to facilitate control flow between a