From 80f80d61db7d02872a5ef6fe1704295198d710ed Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri, 14 Oct 2022 06:15:33 -0700 Subject: Cleans final production mode warnings from H5Shyper.c (#2163) * H5S__hyper_free_span_info() returns herr_t (not checked) * Set up H5S__hyper_free_span_info() error handling * Set up H5S__hyper_free_span() error handling * Added error handling to H5S_HYPER_ADVANCE_SPAN * Handled errors in H5S__hyper_iter_get_seq_list_gen() * Added a production mode build target for -Werror * Committing clang-format changes * Updated names for -Werror checks Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/main.yml | 24 ++- src/H5Shyper.c | 386 ++++++++++++++++++++++++++------------------- 2 files changed, 249 insertions(+), 161 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f75378f..d7e5368 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -269,7 +269,7 @@ jobs: cmake: "Debug" autotools: "debug" - - name: "Ubuntu gcc Autotools -Werror (build only)" + - name: "Ubuntu gcc Autotools -Werror (build only) DBG" os: ubuntu-latest cpp: enable fortran: disable @@ -291,6 +291,28 @@ jobs: cmake: "Debug" autotools: "debug" + - name: "Ubuntu gcc Autotools -Werror (build only) REL" + os: ubuntu-latest + cpp: enable + fortran: disable + java: disable + parallel: disable + mirror_vfd: enable + direct_vfd: enable + deprec_sym: enable + default_api: v114 + toolchain: "" + generator: "autogen" + flags: "CFLAGS=-Werror" + run_tests: false + thread_safety: + - enabled: false + text: "" + build_mode: + - text: "REL" + cmake: "Release" + autotools: "production" + # Sets the job's name from the properties name: "${{ matrix.name }}${{ matrix.build_mode.text }}${{ matrix.thread_safety.text }}" diff --git a/src/H5Shyper.c b/src/H5Shyper.c index f6bc936..650c0c2 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -46,15 +46,16 @@ #define H5S_HYPER_COMPUTE_A_NOT_B 0x04 /* Macro to advance a span, possibly recycling it first */ -#define H5S_HYPER_ADVANCE_SPAN(recover, curr_span, next_span) \ +#define H5S_HYPER_ADVANCE_SPAN(recover, curr_span, next_span, ERR) \ do { \ H5S_hyper_span_t *saved_next_span = (next_span); \ \ /* Check if the span should be recovered */ \ if (recover) { \ - H5S__hyper_free_span(curr_span); \ + if (H5S__hyper_free_span(curr_span) < 0) \ + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, ERR, "unable to free span") \ (recover) = FALSE; \ - } /* end if */ \ + } \ \ /* Set the current span to saved next span */ \ (curr_span) = saved_next_span; \ @@ -117,8 +118,8 @@ static H5S_hyper_span_info_t *H5S__hyper_copy_span_helper(H5S_hyper_span_info_t static H5S_hyper_span_info_t *H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank); static hbool_t H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_span_info_t *span_info2); -static void H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info); -static void H5S__hyper_free_span(H5S_hyper_span_t *span); +static herr_t H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info); +static herr_t H5S__hyper_free_span(H5S_hyper_span_t *span); static herr_t H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], hsize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks, hsize_t **buf); static herr_t H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks, @@ -1432,8 +1433,9 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ int curr_dim; /* Current dimension being operated on */ unsigned u; /* Index variable */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_PACKAGE /* Check args */ HDassert(iter); @@ -1709,7 +1711,8 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Check if we are done */ if (io_elmts_left == 0 || curr_seq >= maxseq) { /* Sanity checks */ - HDassert(curr_span); + if (!curr_span) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "curr_span pointer was NULL") /* Update absolute position */ abs_arr[fast_dim] = curr_span->low + span_elmts; @@ -1839,7 +1842,8 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Set the number of elements used */ *nelem = io_used; - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_get_seq_list_gen() */ /*-------------------------------------------------------------------------- @@ -2757,16 +2761,20 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem static herr_t H5S__hyper_iter_release(H5S_sel_iter_t *iter) { - FUNC_ENTER_PACKAGE_NOERR + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Check args */ HDassert(iter); /* Free the copy of the hyperslab selection span tree */ if (iter->u.hyp.spans != NULL) - H5S__hyper_free_span_info(iter->u.hyp.spans); + if (H5S__hyper_free_span_info(iter->u.hyp.spans) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_release() */ /*-------------------------------------------------------------------------- @@ -3095,10 +3103,10 @@ done: PURPOSE Free a hyperslab span info node USAGE - void H5S__hyper_free_span_info(span_info) + herr_t H5S__hyper_free_span_info(span_info) H5S_hyper_span_info_t *span_info; IN: Span info node to free RETURNS - None + SUCCEED/FAIL DESCRIPTION Free a hyperslab span info node, along with all the span nodes and the 'down spans' from the nodes, if reducing their reference count to zero @@ -3108,13 +3116,16 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static void +static herr_t H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) { - FUNC_ENTER_PACKAGE_NOERR + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ - HDassert(span_info); + if (!span_info) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "span_info pointer was NULL") /* Decrement the span tree's reference count */ span_info->count--; @@ -3132,17 +3143,19 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) next_span = span->next; /* Free the current span */ - H5S__hyper_free_span(span); + if (H5S__hyper_free_span(span) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span") /* Advance to next span */ span = next_span; - } /* end while */ + } /* Free this span info */ span_info = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, span_info); - } /* end if */ + } - FUNC_LEAVE_NOAPI_VOID +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_free_span_info() */ /*-------------------------------------------------------------------------- @@ -3151,10 +3164,10 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) PURPOSE Free a hyperslab span node USAGE - void H5S__hyper_free_span(span) + herr_t H5S__hyper_free_span(span) H5S_hyper_span_t *span; IN: Span node to free RETURNS - None + SUCCEED/FAIL DESCRIPTION Free a hyperslab span node, along with the 'down spans' from the node, if reducing their reference count to zero indicates it is appropriate to @@ -3164,22 +3177,26 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static void +static herr_t H5S__hyper_free_span(H5S_hyper_span_t *span) { - FUNC_ENTER_PACKAGE_NOERR + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(span); /* Decrement the reference count of the 'down spans', freeing them if appropriate */ if (span->down != NULL) - H5S__hyper_free_span_info(span->down); + if (H5S__hyper_free_span_info(span->down) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") /* Free this span */ span = H5FL_FREE(H5S_hyper_span_t, span); - FUNC_LEAVE_NOAPI_VOID +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_free_span() */ /*-------------------------------------------------------------------------- @@ -5737,7 +5754,9 @@ done: static herr_t H5S__hyper_release(H5S_t *space) { - FUNC_ENTER_PACKAGE_NOERR + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Check args */ HDassert(space && H5S_SEL_HYPERSLABS == H5S_GET_SELECT_TYPE(space)); @@ -5748,13 +5767,15 @@ H5S__hyper_release(H5S_t *space) /* Release irregular hyperslab information */ if (space->select.sel_info.hslab) { if (space->select.sel_info.hslab->span_lst != NULL) - H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst); + if (H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "unable to free span info") /* Release space for the hyperslab selection information */ space->select.sel_info.hslab = H5FL_FREE(H5S_hyper_sel_t, space->select.sel_info.hslab); - } /* end if */ + } - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_release() */ /*-------------------------------------------------------------------------- @@ -5814,7 +5835,8 @@ H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) done: if (ret_value == NULL && down != NULL) - H5S__hyper_free_span_info(down); + if (H5S__hyper_free_span_info(down) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_coord_to_span() */ @@ -5987,13 +6009,15 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, unsigned ra } /* end else */ /* Release last span created */ - H5S__hyper_free_span(stop_span); - } /* end if */ + if (H5S__hyper_free_span(stop_span) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span") + } /* Span is disjoint, but has the same "down tree" selection */ /* (If it has a "down tree") */ else if (stop_span->down) { /* Release "down tree" information */ - H5S__hyper_free_span_info(stop_span->down); + if (H5S__hyper_free_span_info(stop_span->down) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") /* Point at earlier span's "down tree" */ stop_span->down = tmp_span->down; @@ -6155,7 +6179,8 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) done: if (ret_value < 0) if (head) - H5S__hyper_free_span_info(head); + if (H5S__hyper_free_span_info(head) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_add_span_element() */ @@ -6683,9 +6708,9 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) /* Allocate a new span_info node */ if (NULL == (new_span_info = H5S__hyper_new_span_info(new_space->extent.rank))) { if (prev_span) - H5S__hyper_free_span(prev_span); + (void)H5S__hyper_free_span(prev_span); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span info") - } /* end if */ + } /* Check for linking into higher span */ if (prev_span) @@ -6737,11 +6762,12 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) done: if (ret_value < 0 && new_space->select.sel_info.hslab->span_lst) { if (new_space->select.sel_info.hslab->span_lst->head) - H5S__hyper_free_span(new_space->select.sel_info.hslab->span_lst->head); + if (H5S__hyper_free_span(new_space->select.sel_info.hslab->span_lst->head) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span") new_space->select.sel_info.hslab->span_lst = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, new_space->select.sel_info.hslab->span_lst); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_simple_higher() */ @@ -7299,7 +7325,8 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, hsize_ done: if (ret_value < 0) if (new_span) - H5S__hyper_free_span(new_span); + if (H5S__hyper_free_span(new_span) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_append_span() */ @@ -7445,7 +7472,7 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance span 'a', leave span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, FAIL); } /* end if */ /* Check if span 'a' overlaps only the lower bound */ /* of span 'b' , up to the upper bound of span 'b' */ @@ -7504,8 +7531,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_a_not_b); - } /* end if */ + if (H5S__hyper_free_span_info(down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } /* Check for additions to the a_and_b list */ if (down_a_and_b) { @@ -7518,8 +7546,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_a_and_b); - } /* end if */ + if (H5S__hyper_free_span_info(down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } /* Check for additions to the b_not_a list */ if (down_b_not_a) { @@ -7532,9 +7561,10 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_b_not_a); - } /* end if */ - } /* end else */ + if (H5S__hyper_free_span_info(down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } + } /* end else */ /* Split off upper part of span 'b' at upper span of span 'a' */ @@ -7546,17 +7576,17 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span") /* Advance span 'a' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, FAIL); /* Make upper part of span 'b' into new span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span, FAIL); recover_b = TRUE; } /* end if */ /* No upper part of span 'b' to split */ else { /* Advance both 'a' and 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, FAIL); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, FAIL); } /* end else */ } /* end if */ /* Check if span 'a' overlaps the lower & upper bound */ @@ -7611,8 +7641,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_a_not_b); - } /* end if */ + if (H5S__hyper_free_span_info(down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } /* Check for additions to the a_and_b list */ if (down_a_and_b) { @@ -7625,8 +7656,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_a_and_b); - } /* end if */ + if (H5S__hyper_free_span_info(down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } /* Check for additions to the b_not_a list */ if (down_b_not_a) { @@ -7639,9 +7671,10 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_b_not_a); - } /* end if */ - } /* end else */ + if (H5S__hyper_free_span_info(down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } + } /* end else */ /* Split off upper part of span 'a' at upper span of span 'b' */ @@ -7651,11 +7684,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span") /* Make upper part of span 'a' the new span 'a' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span, FAIL); recover_a = TRUE; /* Advance span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, FAIL); } /* end if */ /* Check if span 'a' is entirely within span 'b' */ /* AAAAA */ @@ -7715,8 +7748,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_a_not_b); - } /* end if */ + if (H5S__hyper_free_span_info(down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } /* Check for additions to the a_and_b list */ if (down_a_and_b) { @@ -7729,8 +7763,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_a_and_b); - } /* end if */ + if (H5S__hyper_free_span_info(down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } /* Check for additions to the b_not_a list */ if (down_b_not_a) { @@ -7743,9 +7778,10 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_b_not_a); - } /* end if */ - } /* end else */ + if (H5S__hyper_free_span_info(down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } + } /* end else */ /* Check if there is actually an upper part of span 'b' to split off */ if (span_a->high < span_b->high) { @@ -7757,16 +7793,16 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* And advance span 'a' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, FAIL); /* Make upper part of span 'b' the new span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span, FAIL); recover_b = TRUE; } /* end if */ else { /* Advance both span 'a' & span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, FAIL); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, FAIL); } /* end else */ } /* end if */ /* Check if span 'a' overlaps only the upper bound */ @@ -7829,8 +7865,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_a_not_b); - } /* end if */ + if (H5S__hyper_free_span_info(down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } /* Check for additions to the a_and_b list */ if (down_a_and_b) { @@ -7843,8 +7880,9 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_a_and_b); - } /* end if */ + if (H5S__hyper_free_span_info(down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } /* Check for additions to the b_not_a list */ if (down_b_not_a) { @@ -7857,9 +7895,10 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s "can't allocate hyperslab span") /* Release the down span tree generated */ - H5S__hyper_free_span_info(down_b_not_a); - } /* end if */ - } /* end else */ + if (H5S__hyper_free_span_info(down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + } + } /* end else */ /* Split off upper part of span 'a' at upper span of span 'b' */ @@ -7869,11 +7908,11 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Make upper part of span 'a' into new span 'a' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span, FAIL); recover_a = TRUE; /* Advance span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, FAIL); } /* end if */ /* span 'a' must be entirely above span 'b' */ /* AAAAA */ @@ -7889,7 +7928,7 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance span 'b', leave span 'a' */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, FAIL); } /* end else */ } /* end while */ @@ -7911,13 +7950,14 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance to the next 'a' span */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, FAIL); } /* end while */ } /* end if */ else { /* Free the span, if it's generated */ if (recover_a) - H5S__hyper_free_span(span_a); + if (H5S__hyper_free_span(span_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span") } /* end else */ } /* end if */ /* Clean up 'b' spans which haven't been covered yet */ @@ -7938,13 +7978,14 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance to the next 'b' span */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, FAIL); } /* end while */ } /* end if */ else { /* Free the span, if it's generated */ if (recover_b) - H5S__hyper_free_span(span_b); + if (H5S__hyper_free_span(span_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span") } /* end else */ } /* end if */ else @@ -8028,7 +8069,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, NULL); } /* end if */ /* Check if span 'a' overlaps only the lower bound */ /* of span 'b', up to the upper bound of span 'b' */ @@ -8043,7 +8084,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") - } /* end if */ + } else { /* Merge/add lower part of span 'a' with/to merged spans */ if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, @@ -8059,8 +8100,9 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ - H5S__hyper_free_span_info(tmp_spans); - } /* end else */ + if (H5S__hyper_free_span_info(tmp_spans) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info") + } /* Check if there is an upper part of span 'b' */ if (span_a->high < span_b->high) { @@ -8072,16 +8114,16 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, NULL); /* Set new span 'b' to tmp_span */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span, NULL); recover_b = TRUE; } /* end if */ else { /* Advance both span 'a' & 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, NULL); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, NULL); } /* end else */ } /* end if */ /* Check if span 'a' overlaps the lower & upper bound */ @@ -8096,7 +8138,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") - } /* end if */ + } else { /* Merge/add lower part of span 'a' to merged spans */ if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, @@ -8112,8 +8154,9 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ - H5S__hyper_free_span_info(tmp_spans); - } /* end else */ + if (H5S__hyper_free_span_info(tmp_spans) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info") + } /* Copy upper part of span 'a' as new span 'a' (remember to free) */ @@ -8123,11 +8166,11 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set new span 'a' to tmp_span */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span, NULL); recover_a = TRUE; /* Advance span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, NULL); } /* end if */ /* Check if span 'a' is entirely within span 'b' */ /* AAAAA */ @@ -8140,7 +8183,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") - } /* end if */ + } else { /* Check if there is a lower part of span 'b' */ if (span_a->low > span_b->low) { @@ -8162,8 +8205,9 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ - H5S__hyper_free_span_info(tmp_spans); - } /* end else */ + if (H5S__hyper_free_span_info(tmp_spans) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info") + } /* Check if there is an upper part of span 'b' */ if (span_a->high < span_b->high) { @@ -8175,16 +8219,16 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, NULL); /* Set new span 'b' to tmp_span */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, tmp_span, NULL); recover_b = TRUE; } /* end if */ else { /* Advance both spans */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, NULL); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, NULL); } /* end else */ } /* end if */ /* Check if span 'a' overlaps only the upper bound */ @@ -8200,7 +8244,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") - } /* end if */ + } else { /* Check if there is a lower part of span 'b' */ if (span_a->low > span_b->low) { @@ -8222,8 +8266,9 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ - H5S__hyper_free_span_info(tmp_spans); - } /* end else */ + if (H5S__hyper_free_span_info(tmp_spans) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info") + } /* Copy upper part of span 'a' as new span 'a' */ @@ -8233,11 +8278,11 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set new span 'a' to tmp_span */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, tmp_span, NULL); recover_a = TRUE; /* Advance span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, NULL); } /* end if */ /* Span 'a' must be entirely above span 'b' */ /* AAAAA */ @@ -8249,7 +8294,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance span 'b' */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, NULL); } /* end else */ } /* end while */ @@ -8261,7 +8306,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance to next 'a' span, until all processed */ - H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); + H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next, NULL); } /* end while */ } /* end if */ @@ -8273,7 +8318,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance to next 'b' span, until all processed */ - H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); + H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next, NULL); } /* end while */ } /* end if */ } /* end else */ @@ -8284,7 +8329,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf done: if (ret_value == NULL) if (merged_spans) - H5S__hyper_free_span_info(merged_spans); + if (H5S__hyper_free_span_info(merged_spans) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_merge_spans_helper() */ @@ -8334,7 +8380,8 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTMERGE, FAIL, "can't merge hyperslab spans") /* Free the previous spans */ - H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst); + if (H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") /* Point to the new merged spans */ space->select.sel_info.hslab->span_lst = merged_spans; @@ -8496,7 +8543,8 @@ H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't merge hyperslabs") /* Free the memory space for new spans */ - H5S__hyper_free_span_info(new_spans); + if (H5S__hyper_free_span_info(new_spans) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") done: FUNC_LEAVE_NOAPI(ret_value) @@ -9280,9 +9328,10 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, H5S_hyper_span_info_t *s HDassert(space1 == *result); /* Free the current selection */ - H5S__hyper_free_span_info(space1->select.sel_info.hslab->span_lst); + if (H5S__hyper_free_span_info(space1->select.sel_info.hslab->span_lst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") space1->select.sel_info.hslab->span_lst = NULL; - } /* end if */ + } /* Copy space2's spans to *result */ if (!can_own_span2) @@ -9291,7 +9340,7 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, H5S_hyper_span_info_t *s else { (*result)->select.sel_info.hslab->span_lst = space2_span_lst; *span2_owned = TRUE; - } /* end else */ + } /* Reset the number of items in selection */ (*result)->select.num_elem = H5S__hyper_spans_nelem(space2_span_lst); @@ -9362,9 +9411,10 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, H5S_hyper_span_info_t *s HDassert(space1 == *result); /* Free the current selection */ - H5S__hyper_free_span_info(space1->select.sel_info.hslab->span_lst); + if (H5S__hyper_free_span_info(space1->select.sel_info.hslab->span_lst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") space1->select.sel_info.hslab->span_lst = NULL; - } /* end if */ + } /* Reset the number of items in selection */ /* (Will be set below) */ @@ -9451,17 +9501,20 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, H5S_hyper_span_info_t *s /* Convert *result to "none" selection */ if (H5S_select_none(*result) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") - } /* end else */ - } /* end if */ + } + } done: /* Free resources */ if (a_not_b) - H5S__hyper_free_span_info(a_not_b); + if (H5S__hyper_free_span_info(a_not_b) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") if (a_and_b) - H5S__hyper_free_span_info(a_and_b); + if (H5S__hyper_free_span_info(a_and_b) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") if (b_not_a) - H5S__hyper_free_span_info(b_not_a); + if (H5S__hyper_free_span_info(b_not_a) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__fill_in_new_space() */ @@ -9503,7 +9556,8 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], c if (op == H5S_SELECT_SET) { /* Free current selection */ if (NULL != space->select.sel_info.hslab->span_lst) - H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst); + if (H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") /* Set the hyperslab selection to the new span tree */ space->select.sel_info.hslab->span_lst = new_spans; @@ -9513,7 +9567,7 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], c /* Indicate that the new_spans are owned */ new_spans = NULL; - } /* end if */ + } else { hbool_t new_spans_owned = FALSE; hbool_t updated_spans = FALSE; @@ -9546,11 +9600,12 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], c /* Indicate that the new_spans are owned, there's no need to free */ if (new_spans_owned) new_spans = NULL; - } /* end else */ + } done: if (new_spans) - H5S__hyper_free_span_info(new_spans); + if (H5S__hyper_free_span_info(new_spans) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__generate_hyperslab() */ @@ -10964,15 +11019,16 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) udata->ds_low[udata->depth - 1], udata->ds_low[udata->depth - 1], udata->ps_span_info[udata->depth]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]); + if (H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") udata->ps_span_info[udata->depth] = NULL; - } /* end if */ + } /* Ran out of spans, move up one dimension */ udata->depth--; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth]++; - } /* end if */ + } else HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "insufficient elements in destination selection") @@ -11061,7 +11117,7 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) udata->ds_span[udata->depth]->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - } /* end if */ + } else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it @@ -11080,9 +11136,10 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) copied_span_info) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - H5S__hyper_free_span_info(copied_span_info); + if (H5S__hyper_free_span_info(copied_span_info) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") copied_span_info = NULL; - } /* end else */ + } udata->ds_low[udata->depth] += udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->nelem %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; @@ -11097,7 +11154,7 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) udata->ds_span[udata->depth]->high, udata->ds_span[udata->depth]->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - } /* end if */ + } else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it @@ -11110,9 +11167,10 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) udata->ds_rank - udata->depth, udata->ds_low[udata->depth], udata->ds_span[udata->depth]->high, copied_span_info) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - H5S__hyper_free_span_info(copied_span_info); + if (H5S__hyper_free_span_info(copied_span_info) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") copied_span_info = NULL; - } /* end else */ + } udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); } /* end if */ @@ -11152,7 +11210,8 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) udata->ds_low[udata->depth - 1], udata->ps_span_info[udata->depth]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]); + if (H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") udata->ps_span_info[udata->depth] = NULL; /* Ran out of spans, move up one dimension */ @@ -11199,7 +11258,7 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) udata->ds_span[udata->depth]->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - } /* end if */ + } else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it @@ -11218,9 +11277,10 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) copied_span_info) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - H5S__hyper_free_span_info(copied_span_info); + if (H5S__hyper_free_span_info(copied_span_info) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") copied_span_info = NULL; - } /* end else */ + } udata->ds_low[udata->depth] += udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->nelem %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; @@ -11235,7 +11295,7 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) udata->ds_span[udata->depth]->high, udata->ds_span[udata->depth]->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - } /* end if */ + } else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it @@ -11248,9 +11308,10 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) udata->ds_rank - udata->depth, udata->ds_low[udata->depth], udata->ds_span[udata->depth]->high, copied_span_info) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - H5S__hyper_free_span_info(copied_span_info); + if (H5S__hyper_free_span_info(copied_span_info) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") copied_span_info = NULL; - } /* end else */ + } udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); @@ -11300,9 +11361,10 @@ done: /* Cleanup on failure */ if (copied_span_info) { HDassert(ret_value < 0); - H5S__hyper_free_span_info(copied_span_info); + if (H5S__hyper_free_span_info(copied_span_info) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") copied_span_info = NULL; - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_proj_int_build_proj() */ @@ -11564,10 +11626,11 @@ H5S__hyper_proj_int_iterate(H5S_hyper_span_info_t *ss_span_info, const H5S_hyper udata->ds_low[u - 1], udata->ds_low[u - 1], udata->ps_span_info[u]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") - H5S__hyper_free_span_info(udata->ps_span_info[u]); + if (H5S__hyper_free_span_info(udata->ps_span_info[u]) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") udata->ps_span_info[u] = NULL; - } /* end if */ - } /* end if */ + } + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -11724,15 +11787,17 @@ H5S__hyper_project_intersection(H5S_t *src_space, H5S_t *dst_space, H5S_t *src_i done: /* Free ss_span_info_buf */ if (ss_span_info_buf) { - H5S__hyper_free_span_info(ss_span_info_buf); + if (H5S__hyper_free_span_info(ss_span_info_buf) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") ss_span_info_buf = NULL; - } /* end if */ + } /* Free ds_span_info_buf */ if (ds_span_info_buf) { - H5S__hyper_free_span_info(ds_span_info_buf); + if (H5S__hyper_free_span_info(ds_span_info_buf) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") ds_span_info_buf = NULL; - } /* end if */ + } /* Cleanup on error */ if (ret_value < 0) { @@ -11741,10 +11806,11 @@ done: /* Free span trees */ for (u = 0; u < udata.ds_rank; u++) if (udata.ps_span_info[u]) { - H5S__hyper_free_span_info(udata.ps_span_info[u]); + if (H5S__hyper_free_span_info(udata.ps_span_info[u]) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") udata.ps_span_info[u] = NULL; - } /* end if */ - } /* end if */ + } + } #ifndef NDEBUG /* Verify there are no more span trees */ @@ -11753,7 +11819,7 @@ done: for (u = 0; u < H5S_MAX_RANK; u++) HDassert(!udata.ps_span_info[u]); - } /* end block */ + } #endif /* NDEBUG */ FUNC_LEAVE_NOAPI(ret_value) -- cgit v0.12