Partial removal of NDEBUG ifdefs from the library.

This commit is contained in:
Dana Robinson 2017-06-29 14:25:18 -07:00
parent 598856b37e
commit a2b7560aa6
18 changed files with 76 additions and 111 deletions

View File

@ -359,9 +359,9 @@ H5_term_library(void)
if(func) {
fprintf(stderr, "HDF5: infinite loop closing library\n");
fprintf(stderr, " %s\n", loop);
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
HDabort();
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
} /* end if */
} /* end if */

View File

@ -485,7 +485,7 @@ H5_DLL herr_t H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr);
/* Debugging functions */
H5_DLL herr_t H5AC_stats(const H5F_t *f);
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
H5_DLL herr_t H5AC_dump_cache(const H5F_t *f);
H5_DLL herr_t H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr,
void **entry_ptr_ptr);
@ -496,7 +496,7 @@ H5_DLL herr_t H5AC_verify_entry_type(const H5F_t *f, haddr_t addr,
hbool_t *type_ok_ptr);
H5_DLL hbool_t H5AC_get_serialization_in_progress(H5F_t *f);
H5_DLL hbool_t H5AC_cache_is_clean(const H5F_t *f, H5AC_ring_t inner_ring);
#endif /* NDEBUG */ /* end debugging functions */
#endif /* H5_DEBUG_BUILD */ /* end debugging functions */
#endif /* !_H5ACprivate_H */

View File

@ -314,7 +314,7 @@ H5A__open_common(const H5G_loc_t *loc, H5A_t *attr)
HDassert(loc);
HDassert(attr);
#if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG)
#if defined(H5_USING_MEMCHECKER) || defined(H5_DEBUG_BUILD)
/* Clear object location */
if(H5O_loc_reset(&(attr->oloc)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to reset location")
@ -1710,10 +1710,7 @@ H5A_attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip,
break;
default:
HDassert("unknown attribute op type" && 0);
#ifdef NDEBUG
HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unsupported attribute op type")
#endif /* NDEBUG */
} /* end switch */
/* Increment the number of entries passed through */

View File

@ -26,13 +26,6 @@
#ifndef _H5Apkg_H
#define _H5Apkg_H
/*
* Define this to enable debugging.
*/
#ifdef NDEBUG
# undef H5A_DEBUG
#endif
/* Get package's private header */
#include "H5Aprivate.h"

View File

@ -991,14 +991,8 @@ H5B__insert_helper(H5F_t *f, hid_t dxpl_id, H5B_ins_ud_t *bt_ud,
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "internal error: likely corrupt key values")
#endif /* H5_STRICT_FORMAT_CHECKS */
} else if(cmp) {
/*
* We couldn't figure out which branch to follow out of this node. THIS
* IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm.
*/
HDassert("INTERNAL HDF5 ERROR (contact rpm)" && 0);
#ifdef NDEBUG
HDabort();
#endif /* NDEBUG */
/* We couldn't determine which branch to follow out of this node. */
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to find a way out of this node")
} else if(bt->level > 0) {
/*
* Follow a branch out of this node to another subtree.

View File

@ -39,14 +39,10 @@
/**************************/
/*
* Feature: Define this constant if you want to check B-tree consistency
* after each B-tree operation. Note that this slows down the
* library considerably! Debugging the B-tree depends on assert()
* being enabled.
* NOTE: Define H5B_DEBUG if you want to check B-tree consistency
* after each B-tree operation. Note that this slows down the
* library considerably!
*/
#ifdef NDEBUG
# undef H5B_DEBUG
#endif
/****************************/

View File

@ -4670,7 +4670,7 @@ typedef struct H5C_tag_info_t {
* get_entry_ptr_from_addr_counter: Counter used to track the number of
* times the H5C_get_entry_ptr_from_addr() function has been
* called successfully. This field is only defined when
* NDEBUG is not #defined.
* H5_DEBUG_BUILD is #defined.
*
****************************************************************************/
struct H5C_t {
@ -4903,9 +4903,9 @@ struct H5C_t {
char prefix[H5C__PREFIX_LEN];
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
int64_t get_entry_ptr_from_addr_counter;
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
};
/* Define typedef for tagged cache entry iteration callbacks */

View File

@ -207,20 +207,20 @@
#define H5C__UPDATE_PAGE_BUFFER_FLAG 0x40000 /* Set during parallel I/O */
/* Debugging/sanity checking/statistics settings */
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
#define H5C_DO_SANITY_CHECKS 1
#define H5C_DO_SLIST_SANITY_CHECKS 0
#define H5C_DO_TAGGING_SANITY_CHECKS 1
#define H5C_DO_EXTREME_SANITY_CHECKS 0
#else /* NDEBUG */
#else /* H5_DEBUG_BUILD */
/* With rare execptions, the following defines should be set
* to 0 if NDEBUG is defined
* to 0 if not using a debug build.
*/
#define H5C_DO_SANITY_CHECKS 0
#define H5C_DO_SLIST_SANITY_CHECKS 0
#define H5C_DO_TAGGING_SANITY_CHECKS 0
#define H5C_DO_EXTREME_SANITY_CHECKS 0
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/* Cork actions: cork/uncork/get cork status of an object */
#define H5C__SET_CORK 0x1
@ -242,11 +242,11 @@
* debug mode, and 0 in production mode..
*/
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
#define H5C_COLLECT_CACHE_STATS 1
#else /* NDEBUG */
#else /* H5_DEBUG_BUILD */
#define H5C_COLLECT_CACHE_STATS 0
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/* H5C_COLLECT_CACHE_ENTRY_STATS controls collection of statistics
* in individual cache entries.
@ -1559,7 +1559,7 @@ typedef int H5C_ring_t;
* a single cache serialization.
*
* This is a debugging field, and thus is maintained only if
* NDEBUG is undefined.
* H5_DEBUG_BUILD is defined.
*
* Fields supporting tagged entries:
*
@ -1669,9 +1669,9 @@ typedef struct H5C_cache_entry_t {
int32_t age;
hbool_t prefetched_dirty;
#ifndef NDEBUG /* debugging field */
#ifdef H5_DEBUG_BUILD /* debugging field */
int serialization_count;
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/* fields supporting tag lists */
struct H5C_cache_entry_t *tl_next;
@ -2332,7 +2332,7 @@ H5_DLL herr_t H5C_mark_entries_as_clean(H5F_t *f, hid_t dxpl_id, unsigned ce_arr
haddr_t *ce_array_ptr);
#endif /* H5_HAVE_PARALLEL */
#ifndef NDEBUG /* debugging functions */
#ifdef H5_DEBUG_BUILD /* debugging functions */
H5_DLL herr_t H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name);
H5_DLL herr_t H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name);
H5_DLL hbool_t H5C_get_serialization_in_progress(const H5C_t *cache_ptr);
@ -2349,7 +2349,7 @@ H5_DLL herr_t H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr,
const H5C_class_t *expected_type, hbool_t *in_cache_ptr,
hbool_t *type_ok_ptr);
H5_DLL herr_t H5C_validate_index_list(H5C_t *cache_ptr);
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
#endif /* !_H5Cprivate_H */

View File

@ -2510,7 +2510,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
type_info->mem_type, fill_space, io_info->md_dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "filling buf failed")
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
/* Make sure the total number of elements written (including fill
* values) >= nelmts */
{
@ -2523,9 +2523,10 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
/* Verify number of elements is correct. Note that since we
* don't check for overlap we can't assert that these are equal
*/
HDassert((tot_nelmts + (hsize_t)select_nelmts) >= nelmts);
if((tot_nelmts + (hsize_t)select_nelmts) < nelmts)
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "number of elements is incorrect")
} /* end block */
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
} /* end if */
} /* end if */

View File

@ -877,7 +877,7 @@ H5EA_close(H5EA_t *ea, hid_t dxpl_id))
if(pending_delete) {
H5EA_hdr_t *hdr; /* Another pointer to extensible array header */
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
{
unsigned hdr_status = 0; /* Header's status in the metadata cache */
@ -886,11 +886,14 @@ H5EA_close(H5EA_t *ea, hid_t dxpl_id))
H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for extensible array header")
/* Sanity checks on header */
HDassert(hdr_status & H5AC_ES__IN_CACHE);
HDassert(hdr_status & H5AC_ES__IS_PINNED);
HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED));
if(!(hdr_status & H5AC_ES__IN_CACHE))
H5E_THROW(H5E_BADVALUE, "extensible array header not in cache")
if(!(hdr_status & H5AC_ES__IS_PINNED))
H5E_THROW(H5E_BADVALUE, "extensible array header not pinned")
if(hdr_status & H5AC_ES__IS_PROTECTED)
H5E_THROW(H5E_BADVALUE, "extensible array header is incorrectly protected")
}
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/* Lock the array header into memory */
/* (OK to pass in NULL for callback context, since we know the header must be in the cache) */

View File

@ -298,7 +298,7 @@ H5F__evict_cache_entries(H5F_t *f, hid_t dxpl_id)
if(H5AC_evict(f, dxpl_id) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict all except pinned entries")
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
{
unsigned status = 0;
uint32_t cur_num_entries;
@ -319,7 +319,7 @@ H5F__evict_cache_entries(H5F_t *f, hid_t dxpl_id)
if(cur_num_entries != 1)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "number of cache entries is not correct")
}
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
done:
FUNC_LEAVE_NOAPI(ret_value);

View File

@ -43,15 +43,6 @@
#include "H5PBprivate.h" /* Page buffer */
#include "H5UCprivate.h" /* Reference counted object functions */
/*
* Feature: Define this constant on the compiler command-line if you want to
* see some debugging messages on the debug stream.
*/
#ifdef NDEBUG
# undef H5F_DEBUG
#endif
/* Superblock status flags */
#define H5F_SUPER_WRITE_ACCESS 0x01
#define H5F_SUPER_FILE_OK 0x02

View File

@ -32,13 +32,6 @@
#include "H5ACprivate.h" /* Metadata cache */
#include "H5Fprivate.h" /* File access */
/*
* Feature: Define H5HL_DEBUG on the compiler command line if you want to
* enable diagnostic messages from this layer.
*/
#ifdef NDEBUG
# undef H5HL_DEBUG
#endif
#define H5HL_ALIGN(X) ((((unsigned)X)+7)&(unsigned)(~0x07)) /* align on 8-byte boundary */

View File

@ -127,7 +127,7 @@ H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied,
HDassert(new_gap_loc);
HDassert(new_gap_size);
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
if(chunkno > 0) {
unsigned chk_proxy_status = 0; /* Object header chunk proxy entry cache status */
@ -136,9 +136,10 @@ if(chunkno > 0) {
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check metadata cache status for object header chunk proxy")
/* Make certain that object header is protected */
HDassert(chk_proxy_status & H5AC_ES__IS_PROTECTED);
if(!(chk_proxy_status & H5AC_ES__IS_PROTECTED))
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "chunk proxy is not protected")
} /* end if */
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/* Check for existing null message in chunk */
merged_with_null = FALSE;

View File

@ -171,11 +171,11 @@
#define H5O_DECODEIO_DIRTY 0x02u /* OUT: message has been changed */
/* Macro to incremend ndecode_dirtied (only if we are debugging) */
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
#define INCR_NDECODE_DIRTIED(OH) (OH)->ndecode_dirtied++;
#else /* NDEBUG */
#else /* H5_DEBUG_BUILD */
#define INCR_NDECODE_DIRTIED(OH) ;
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/* Load native information for a message, if it's not already present */
/* (Only works for messages with decode callback) */
@ -193,11 +193,11 @@
if((ioflags & H5O_DECODEIO_DIRTY) && (H5F_get_intent((F)) & H5F_ACC_RDWR)) { \
(MSG)->dirty = TRUE; \
/* Increment the count of messages dirtied by decoding, but */ \
/* only ifndef NDEBUG */ \
/* only debugging */ \
INCR_NDECODE_DIRTIED(OH) \
} \
\
/* Set the message's "shared info", if it's shareable */ \
/* Set the message's "shared info", if it's shareable */ \
if((MSG)->flags & H5O_MSG_FLAG_SHAREABLE) { \
HDassert(msg_type->share_flags & H5O_SHARE_IS_SHARABLE); \
H5O_UPDATE_SHARED((H5O_shared_t *)(MSG)->native, H5O_SHARE_TYPE_HERE, (F), msg_type->id, (MSG)->crt_idx, (OH)->chunk[0].addr) \
@ -292,9 +292,9 @@ struct H5O_t {
* versions of the library)
*/
#endif /* H5O_ENABLE_BAD_MESG_COUNT */
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
size_t ndecode_dirtied; /* Number of messages dirtied by decoding */
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/* Chunk management information (not stored) */
size_t rc; /* Reference count of [continuation] chunks using this structure */

View File

@ -527,16 +527,17 @@ H5SM_create_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id)
if(H5HF_get_heap_addr(fheap, &(header->heap_addr)) < 0)
HGOTO_ERROR(H5E_SOHM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address")
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
{
size_t fheap_id_len; /* Size of a fractal heap ID */
/* Sanity check ID length */
if(H5HF_get_id_len(fheap, &fheap_id_len) < 0)
HGOTO_ERROR(H5E_SOHM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length")
HDassert(fheap_id_len == H5O_FHEAP_ID_LEN);
if(fheap_id_len != H5O_FHEAP_ID_LEN)
HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "incorrect fractal heap ID length")
}
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
done:
/* Release resources */
@ -1057,7 +1058,7 @@ H5SM_try_share(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned defer_flags,
unsigned cache_flags = H5AC__NO_FLAGS_SET;
ssize_t index_num;
htri_t tri_ret;
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
unsigned deferred_type = -1u;
#endif
htri_t ret_value = TRUE;
@ -1069,13 +1070,13 @@ H5SM_try_share(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned defer_flags,
* holds true; otherwise we can leave now if it wasn't shared in the DEFER
* pass. */
if(defer_flags & H5SM_WAS_DEFERRED)
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
deferred_type = ((H5O_shared_t *)mesg)->type;
#else /* NDEBUG */
#else /* H5_DEBUG_BUILD */
if((((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_HERE)
&& (((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_SOHM))
HGOTO_DONE(FALSE);
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/* "trivial" sharing checks */
if(mesg_flags && (*mesg_flags & H5O_MSG_FLAG_DONTSHARE))
@ -1130,16 +1131,18 @@ done:
HDassert((ret_value != TRUE)
|| ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE
|| ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM);
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
/* If we previously deferred this operation, make sure the saved message
* type is the same as the one we get here. */
* type is the same as the one we get here.
*/
if(defer_flags & H5SM_WAS_DEFERRED)
HDassert(deferred_type == ((H5O_shared_t *)mesg)->type);
#endif /* NDEBUG */
if(deferred_type != ((H5O_shared_t *)mesg)->type)
HDONE_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "deferred type doesn't match")
#endif /* H5_DEBUG_BUILD */
/* Release the master SOHM table */
if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0)
HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table")
HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table")
FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
} /* end H5SM_try_share() */

View File

@ -26,13 +26,6 @@
#ifndef _H5Tpkg_H
#define _H5Tpkg_H
/*
* Define this to enable debugging.
*/
#ifdef NDEBUG
# undef H5T_DEBUG
#endif
/* Get package's private header */
#include "H5Tprivate.h"

View File

@ -1559,20 +1559,20 @@ extern char *strdup(const char *s);
/*
* A macro for detecting over/under-flow when casting between types
*/
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
#define H5_CHECK_OVERFLOW(var, vartype, casttype) \
{ \
casttype _tmp_overflow = (casttype)(var); \
HDassert((var) == (vartype)_tmp_overflow); \
}
#else /* NDEBUG */
#else /* H5_DEBUG_BUILD */
#define H5_CHECK_OVERFLOW(var, vartype, casttype)
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
/*
* A macro for detecting over/under-flow when assigning between types
*/
#ifndef NDEBUG
#ifdef H5_DEBUG_BUILD
#define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \
{ \
srctype _tmp_src = (srctype)(src); \
@ -1626,10 +1626,10 @@ extern char *strdup(const char *s);
#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \
H5_GLUE4(ASSIGN_,srctype,_TO_,dsttype)(dst,dsttype,src,srctype)\
#else /* NDEBUG */
#else /* H5_DEBUG_BUILD */
#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \
(dst) = (dsttype)(src);
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
#if defined(H5_HAVE_WINDOW_PATH)
@ -1974,23 +1974,23 @@ extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */
#define H5_PACKAGE_INIT(pkg_init, err)
#endif /* H5_MY_PKG */
#ifndef NDEBUG
/* Check the function name (requires assert()) */
#if defined(H5_DEBUG_BUILD) && !defined(NDEBUG)
#define FUNC_ENTER_CHECK_NAME(asrt) \
{ \
static hbool_t func_check = FALSE; \
\
if(!func_check) { \
/* Check function naming status */ \
HDassert(asrt && "Function naming conventions are incorrect - check H5_IS_API|PUB|PRIV|PKG macros in H5private.h (this is usually due to an incorrect number of underscores)"); \
HDassert(asrt && "Function naming conventions are incorrect - check H5_IS_API|PUB|PRIV|PKG macros in H5private.h (this is usually due to an incorrect number of underscores in a new or changed function name)"); \
\
/* Don't check again */ \
func_check = TRUE; \
} /* end if */ \
} /* end scope */
#else /* NDEBUG */
#else /* H5_DEBUG_BUILD */
#define FUNC_ENTER_CHECK_NAME(asrt)
#endif /* NDEBUG */
#endif /* H5_DEBUG_BUILD */
#define FUNC_ENTER_COMMON(asrt) \