summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2022-07-11 17:27:40 (GMT)
committerGitHub <noreply@github.com>2022-07-11 17:27:40 (GMT)
commit0412d3f292b255da700d865fd1eb990e05c038bb (patch)
tree1d4ad4ab8d32b0452a30abae4c52ebd9fed17f43 /test
parentfa7caf843508b250f085e88cf5edfc2606da1205 (diff)
downloadhdf5-0412d3f292b255da700d865fd1eb990e05c038bb.zip
hdf5-0412d3f292b255da700d865fd1eb990e05c038bb.tar.gz
hdf5-0412d3f292b255da700d865fd1eb990e05c038bb.tar.bz2
Fixes for production mode gcc warnings (#1873)
* Fixes for production mode gcc warnings With the strict-overflow changes, this brings the number of warnings in the C library w/ gcc 12 to zero. * Fix typo * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r--test/cache_common.c12
-rw-r--r--test/h5test.c30
2 files changed, 27 insertions, 15 deletions
diff --git a/test/cache_common.c b/test/cache_common.c
index 9becfa8..41aa128 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -4977,13 +4977,17 @@ check_and_validate_cache_hit_rate(hid_t file_id, double *hit_rate_ptr, hbool_t d
else {
cache_ptr = file_ptr->shared->cache;
+ if (NULL == cache_ptr) {
+ pass = FALSE;
+ failure_mssg = "NULL cache pointer";
+ }
}
}
/* verify that we can access the cache data structure */
if (pass) {
- if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) {
+ if (cache_ptr->magic != H5C__H5C_T_MAGIC) {
pass = FALSE;
failure_mssg = "Can't access cache resize_ctl.";
@@ -5102,13 +5106,17 @@ check_and_validate_cache_size(hid_t file_id, size_t *max_size_ptr, size_t *min_c
else {
cache_ptr = file_ptr->shared->cache;
+ if (NULL == cache_ptr) {
+ pass = FALSE;
+ failure_mssg = "NULL cache pointer";
+ }
}
}
/* verify that we can access the cache data structure */
if (pass) {
- if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) {
+ if (cache_ptr->magic != H5C__H5C_T_MAGIC) {
pass = FALSE;
failure_mssg = "Can't access cache data structure.";
diff --git a/test/h5test.c b/test/h5test.c
index f39825c..8ec6047 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -99,10 +99,10 @@ static const char *multi_letters = "msbrglo";
#define MESSAGE_TIMEOUT 300 /* Timeout in seconds */
/* Buffer to construct path in and return pointer to */
-static char srcdir_path[1024] = "";
+static char srcdir_path[1024];
/* Buffer to construct file in and return pointer to */
-static char srcdir_testpath[1024] = "";
+static char srcdir_testpath[1024];
/* The strings that correspond to library version bounds H5F_libver_t in H5Fpublic.h */
/* This is used by h5_get_version_string() */
@@ -1997,7 +1997,7 @@ done:
*
* Purpose: Append the test file name to the srcdir path and return the whole string
*
- * Return: The string
+ * Return: The string or NULL (errors or not enough space)
*
*-------------------------------------------------------------------------
*/
@@ -2008,16 +2008,20 @@ H5_get_srcdir_filename(const char *filename)
/* Check for error */
if (NULL == srcdir)
- return (NULL);
- else {
- /* Build path to test file */
- if ((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) {
- HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename);
- return (srcdir_testpath);
- } /* end if */
- else
- return (NULL);
- } /* end else */
+ return NULL;
+
+ /* Build path to test file. We're checking the length so suppress
+ * the gcc format-truncation warning.
+ */
+ if ((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) {
+ H5_GCC_DIAG_OFF("format-truncation")
+ HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename);
+ H5_GCC_DIAG_ON("format-truncation")
+ return srcdir_testpath;
+ }
+
+ /* If not enough space, just return NULL */
+ return NULL;
} /* end H5_get_srcdir_filename() */
/*-------------------------------------------------------------------------