summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-11-13 04:36:32 (GMT)
committerGitHub <noreply@github.com>2021-11-13 04:36:32 (GMT)
commitd224f98dbc63104b523186c9b708c2a05f6e4374 (patch)
treeb8396445648acd3c5f0cfe0dda215ce4cced0d2a
parent08b1c6ac3c7d65fe5bfc1d70b68f66d633fa5999 (diff)
downloadhdf5-d224f98dbc63104b523186c9b708c2a05f6e4374.zip
hdf5-d224f98dbc63104b523186c9b708c2a05f6e4374.tar.gz
hdf5-d224f98dbc63104b523186c9b708c2a05f6e4374.tar.bz2
Quiets most const warnings in the fractal heap code (#1188)
-rw-r--r--src/H5HF.c19
-rw-r--r--src/H5HFcache.c12
-rw-r--r--src/H5HFman.c10
3 files changed, 32 insertions, 9 deletions
diff --git a/src/H5HF.c b/src/H5HF.c
index b333795..8e69032 100644
--- a/src/H5HF.c
+++ b/src/H5HF.c
@@ -114,8 +114,14 @@ H5HF__op_write(const void *obj, size_t obj_len, void *op_data)
{
FUNC_ENTER_PACKAGE_NOERR
- /* Perform "write", using memcpy() */
- H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */
+ /* Perform "write", using memcpy()
+ *
+ * We cast away const here because no obj pointer that was originally
+ * const should ever arrive here.
+ */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
+ H5MM_memcpy((void *)obj, op_data, obj_len);
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF__op_write() */
@@ -347,10 +353,15 @@ H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id /*out*/)
/* Check for 'huge' object */
if (size > hdr->max_man_size) {
- /* Store 'huge' object in heap */
- /* (Casting away const OK - QAK) */
+ /* Store 'huge' object in heap
+ *
+ * Although not ideal, we can quiet the const warning here becuase no
+ * obj pointer that was originally const should ever arrive here.
+ */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (H5HF__huge_insert(hdr, size, (void *)obj, id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'huge' object in fractal heap")
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
} /* end if */
/* Check for 'tiny' object */
else if (size <= hdr->tiny_max_len) {
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index fde5a4f..5b50725 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -1655,9 +1655,15 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
/* Update info about direct block */
udata->decompressed = TRUE;
len = nbytes;
- } /* end if */
- else
- read_buf = (void *)image; /* Casting away const OK - QAK */
+ }
+ else {
+ /* If the data are unfiltered, we just point to the image, which we
+ * never modify. Casting away const is okay here.
+ */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
+ read_buf = (void *)image;
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
+ }
/* Decode checksum */
chk_size = (size_t)(H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) - H5HF_SIZEOF_CHKSUM);
diff --git a/src/H5HFman.c b/src/H5HFman.c
index 427be00..a362d99 100644
--- a/src/H5HFman.c
+++ b/src/H5HFman.c
@@ -487,10 +487,16 @@ H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj)
HDassert(id);
HDassert(obj);
- /* Call the internal 'op' routine routine */
- /* (Casting away const OK - QAK) */
+ /* Call the internal 'op' routine routine
+ *
+ * In this case, the callback operation needs to modify the obj buffer that
+ * was passed in as const. We quiet the warning here because an obj pointer
+ * that was originally const should *never* arrive here.
+ */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (H5HF__man_op_real(hdr, id, H5HF__op_write, (void *)obj, H5HF_OP_MODIFY) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
done:
FUNC_LEAVE_NOAPI(ret_value)