summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2022-04-05 13:20:19 (GMT)
committerGitHub <noreply@github.com>2022-04-05 13:20:19 (GMT)
commitbddd148fd29deb18439767c416199914845431b8 (patch)
tree9afaa591016c2ae1fe1978d4573c80303420d922 /src
parent99ba670f6add3bf83c0361537230e686f3976d1e (diff)
downloadhdf5-bddd148fd29deb18439767c416199914845431b8.zip
hdf5-bddd148fd29deb18439767c416199914845431b8.tar.gz
hdf5-bddd148fd29deb18439767c416199914845431b8.tar.bz2
Misc fixes from develop nov21 - feb22 (#1580)
* Make default to build high-level tools the same as default for (#1234) high-level library. * Updated README.txt to README.md (#1375) * H5Lexists docs: Removed reference to 1.8.16 since the change is the 1.8.x releases, HDFFV-11289 * H5Oget_info_by_name, name can be any object, not just a group * Converted README.txt to README.md and updated files referring to README.txt to README.md. * removed references to README.txt * updated MANIFEST * Snprintf2 (#1399) * Replaced many uses of sprintf with safer snprintf Many very straightforward, but in a few cases added a length parameter to some private functions, because buffer length was otherwise unknowable. * Removed unnecessary use of static on small buffers This improves thread safety. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Replaced several uses of sprintf with safer snprintf (#1383) * Replaced several uses of sprintf with safer snprintf * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Used clang-tidy to change all floating point f suffixes to F (#1359) * Added another missing override keyword on a dtor (#1384) * Creating FUNDING.yml (#1427) * Creating FUNDING.yml Will add sponsor this project widget to the repo's page. * Correct file name Add sponsor widget; filename typo fixed. * Update MANIFEST * Fixed AbstractDs::getVarLenType documentation (#1441) * Committing clang-format changes * Open bsd fixes (#1195) * Fix end of line alignment. Co-authored-by: Scot Breitenfeld <brtnfld@hdfgroup.org> Co-authored-by: Sean McBride <sean@rogue-research.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: loricooperhdf <lori.cooper@hdfgroup.org> Co-authored-by: myd7349 <myd7349@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c2
-rw-r--r--src/H5Dchunk.c4
-rw-r--r--src/H5Dearray.c4
-rw-r--r--src/H5Dfarray.c4
-rw-r--r--src/H5EAdbg.c6
-rw-r--r--src/H5EAtest.c2
-rw-r--r--src/H5FAtest.c2
-rw-r--r--src/H5Odtype.c38
-rw-r--r--src/H5PLpath.c7
-rw-r--r--src/H5Tconv.c2
-rw-r--r--src/H5VLpassthru.c13
-rw-r--r--src/H5private.h2
12 files changed, 43 insertions, 43 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 0f35f7f..87ea0b7 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -333,7 +333,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co
aux_ptr->sync_point_done = NULL;
aux_ptr->p0_image_len = 0;
- HDsprintf(prefix, "%d:", mpi_rank);
+ HDsnprintf(prefix, sizeof(prefix), "%d:", mpi_rank);
if (mpi_rank == 0) {
if (NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL)))
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 9d51fee..6d4887e 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -6773,10 +6773,10 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers)
miss_rate = 0.0;
}
if (miss_rate > 100) {
- HDsprintf(ascii, "%7d%%", (int)(miss_rate + 0.5));
+ HDsnprintf(ascii, sizeof(ascii), "%7d%%", (int)(miss_rate + 0.5));
}
else {
- HDsprintf(ascii, "%7.2f%%", miss_rate);
+ HDsnprintf(ascii, sizeof(ascii), "%7.2f%%", miss_rate);
}
HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", "raw data chunks", rdcc->stats.nhits,
diff --git a/src/H5Dearray.c b/src/H5Dearray.c
index abce233..cd52b66 100644
--- a/src/H5Dearray.c
+++ b/src/H5Dearray.c
@@ -417,7 +417,7 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void
HDassert(elmt);
/* Print element */
- HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx);
+ HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx);
HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt);
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -573,7 +573,7 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const
HDassert(elmt);
/* Print element */
- HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx);
+ HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx);
HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr,
elmt->nbytes, elmt->filter_mask);
diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c
index 0741e8f..ab0f0f8 100644
--- a/src/H5Dfarray.c
+++ b/src/H5Dfarray.c
@@ -415,7 +415,7 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void
HDassert(elmt);
/* Print element */
- HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx);
+ HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx);
HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt);
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -675,7 +675,7 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const
HDassert(elmt);
/* Print element */
- HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx);
+ HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx);
HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr,
elmt->nbytes, elmt->filter_mask);
diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c
index b0e564c..b377422 100644
--- a/src/H5EAdbg.c
+++ b/src/H5EAdbg.c
@@ -237,7 +237,7 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde
HDfprintf(stream, "%*sData Block Addresses in Index Block:\n", indent, "");
for (u = 0; u < iblock->ndblk_addrs; u++) {
/* Print address */
- HDsprintf(temp_str, "Address #%u:", u);
+ HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u);
HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str,
iblock->dblk_addrs[u]);
} /* end for */
@@ -252,7 +252,7 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde
HDfprintf(stream, "%*sSuper Block Addresses in Index Block:\n", indent, "");
for (u = 0; u < iblock->nsblk_addrs; u++) {
/* Print address */
- HDsprintf(temp_str, "Address #%u:", u);
+ HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u);
HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str,
iblock->sblk_addrs[u]);
} /* end for */
@@ -341,7 +341,7 @@ H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth,
HDfprintf(stream, "%*sData Block Addresses in Super Block:\n", indent, "");
for (u = 0; u < sblock->ndblks; u++) {
/* Print address */
- HDsprintf(temp_str, "Address #%u:", u);
+ HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u);
HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str,
sblock->dblk_addrs[u]);
} /* end for */
diff --git a/src/H5EAtest.c b/src/H5EAtest.c
index 7924eaa..24efbc2 100644
--- a/src/H5EAtest.c
+++ b/src/H5EAtest.c
@@ -322,7 +322,7 @@ H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *
HDassert(elmt);
/* Print element */
- HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
+ HDsnprintf(temp_str, sizeof(temp_str), "Element #%llu:", (unsigned long long)idx);
HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str,
(unsigned long long)*(const uint64_t *)elmt);
diff --git a/src/H5FAtest.c b/src/H5FAtest.c
index 384a657..b57f562 100644
--- a/src/H5FAtest.c
+++ b/src/H5FAtest.c
@@ -303,7 +303,7 @@ H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *
HDassert(elmt);
/* Print element */
- HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx);
+ HDsnprintf(temp_str, sizeof(temp_str), "Element #%llu:", (unsigned long long)idx);
HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str,
(unsigned long long)*(const uint64_t *)elmt);
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 1be9522..d17e3d0 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -1731,7 +1731,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_NO_CLASS:
case H5T_NCLASSES:
default:
- HDsprintf(buf, "H5T_CLASS_%d", (int)(dt->shared->type));
+ HDsnprintf(buf, sizeof(buf), "H5T_CLASS_%d", (int)(dt->shared->type));
s = buf;
break;
} /* end switch */
@@ -1746,7 +1746,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
"Number of members:", dt->shared->u.compnd.nmembs);
for (i = 0; i < dt->shared->u.compnd.nmembs; i++) {
- HDsprintf(buf, "Member %u:", i);
+ HDsnprintf(buf, sizeof(buf), "Member %u:", i);
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.compnd.memb[i].name);
HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3),
"Byte offset:", (unsigned long)(dt->shared->u.compnd.memb[i].offset));
@@ -1759,7 +1759,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
"Number of members:", dt->shared->u.enumer.nmembs);
for (i = 0; i < dt->shared->u.enumer.nmembs; i++) {
- HDsprintf(buf, "Member %u:", i);
+ HDsnprintf(buf, sizeof(buf), "Member %u:", i);
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.enumer.name[i]);
HDfprintf(stream, "%*s%-*s 0x", indent, "", fwidth, "Raw bytes of value:");
for (k = 0; k < dt->shared->parent->shared->size; k++)
@@ -1799,13 +1799,14 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_CSET_RESERVED_13:
case H5T_CSET_RESERVED_14:
case H5T_CSET_RESERVED_15:
- HDsprintf(buf, "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.cset));
+ HDsnprintf(buf, sizeof(buf), "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.cset));
s = buf;
break;
case H5T_CSET_ERROR:
default:
- HDsprintf(buf, "Unknown character set: %d", (int)(dt->shared->u.atomic.u.s.cset));
+ HDsnprintf(buf, sizeof(buf), "Unknown character set: %d",
+ (int)(dt->shared->u.atomic.u.s.cset));
s = buf;
break;
} /* end switch */
@@ -1837,13 +1838,14 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_STR_RESERVED_13:
case H5T_STR_RESERVED_14:
case H5T_STR_RESERVED_15:
- HDsprintf(buf, "H5T_STR_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.pad));
+ HDsnprintf(buf, sizeof(buf), "H5T_STR_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.pad));
s = buf;
break;
case H5T_STR_ERROR:
default:
- HDsprintf(buf, "Unknown string padding: %d", (int)(dt->shared->u.atomic.u.s.pad));
+ HDsnprintf(buf, sizeof(buf), "Unknown string padding: %d",
+ (int)(dt->shared->u.atomic.u.s.pad));
s = buf;
break;
} /* end switch */
@@ -1862,7 +1864,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_VLEN_BADTYPE:
case H5T_VLEN_MAXTYPE:
default:
- HDsprintf(buf, "H5T_VLEN_%d", dt->shared->u.vlen.type);
+ HDsnprintf(buf, sizeof(buf), "H5T_VLEN_%d", dt->shared->u.vlen.type);
s = buf;
break;
} /* end switch */
@@ -1880,7 +1882,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_LOC_BADLOC:
case H5T_LOC_MAXLOC:
default:
- HDsprintf(buf, "H5T_LOC_%d", (int)dt->shared->u.vlen.loc);
+ HDsnprintf(buf, sizeof(buf), "H5T_LOC_%d", (int)dt->shared->u.vlen.loc);
s = buf;
break;
} /* end switch */
@@ -1911,13 +1913,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_CSET_RESERVED_13:
case H5T_CSET_RESERVED_14:
case H5T_CSET_RESERVED_15:
- HDsprintf(buf, "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.vlen.cset));
+ HDsnprintf(buf, sizeof(buf), "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.vlen.cset));
s = buf;
break;
case H5T_CSET_ERROR:
default:
- HDsprintf(buf, "Unknown character set: %d", (int)(dt->shared->u.vlen.cset));
+ HDsnprintf(buf, sizeof(buf), "Unknown character set: %d", (int)(dt->shared->u.vlen.cset));
s = buf;
break;
} /* end switch */
@@ -1949,13 +1951,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_STR_RESERVED_13:
case H5T_STR_RESERVED_14:
case H5T_STR_RESERVED_15:
- HDsprintf(buf, "H5T_STR_RESERVED_%d", (int)(dt->shared->u.vlen.pad));
+ HDsnprintf(buf, sizeof(buf), "H5T_STR_RESERVED_%d", (int)(dt->shared->u.vlen.pad));
s = buf;
break;
case H5T_STR_ERROR:
default:
- HDsprintf(buf, "Unknown string padding: %d", (int)(dt->shared->u.vlen.pad));
+ HDsnprintf(buf, sizeof(buf), "Unknown string padding: %d", (int)(dt->shared->u.vlen.pad));
s = buf;
break;
} /* end switch */
@@ -1995,7 +1997,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_ORDER_ERROR:
default:
- HDsprintf(buf, "H5T_ORDER_%d", dt->shared->u.atomic.order);
+ HDsnprintf(buf, sizeof(buf), "H5T_ORDER_%d", dt->shared->u.atomic.order);
s = buf;
break;
} /* end switch */
@@ -2069,9 +2071,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_NPAD:
default:
if (dt->shared->u.atomic.u.f.pad < 0)
- HDsprintf(buf, "H5T_PAD_%d", -(dt->shared->u.atomic.u.f.pad));
+ HDsnprintf(buf, sizeof(buf), "H5T_PAD_%d", -(dt->shared->u.atomic.u.f.pad));
else
- HDsprintf(buf, "bit-%d", dt->shared->u.atomic.u.f.pad);
+ HDsnprintf(buf, sizeof(buf), "bit-%d", dt->shared->u.atomic.u.f.pad);
s = buf;
break;
} /* end switch */
@@ -2092,7 +2094,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_NORM_ERROR:
default:
- HDsprintf(buf, "H5T_NORM_%d", (int)(dt->shared->u.atomic.u.f.norm));
+ HDsnprintf(buf, sizeof(buf), "H5T_NORM_%d", (int)(dt->shared->u.atomic.u.f.norm));
s = buf;
} /* end switch */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Normalization:", s);
@@ -2129,7 +2131,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt
case H5T_SGN_ERROR:
case H5T_NSGN:
default:
- HDsprintf(buf, "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign));
+ HDsnprintf(buf, sizeof(buf), "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign));
s = buf;
break;
} /* end switch */
diff --git a/src/H5PLpath.c b/src/H5PLpath.c
index 39a7d0d..d16d8b2 100644
--- a/src/H5PLpath.c
+++ b/src/H5PLpath.c
@@ -706,8 +706,9 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type
HDassert(plugin_path);
HDassert(iter_op);
- /* Specify a file mask. *.* = We want everything! */
- HDsprintf(service, "%s\\*.dll", plugin_path);
+ /* Specify a file mask. *.* = We want everything! -
+ * skip the path if the directory can't be opened */
+ HDsnprintf(service, sizeof(service), "%s\\*.dll", plugin_path);
if ((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE)
HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, H5_ITER_ERROR, "can't open directory")
@@ -931,7 +932,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo
*found = FALSE;
/* Specify a file mask. *.* = We want everything! */
- HDsprintf(service, "%s\\*.dll", dir);
+ HDsnprintf(service, sizeof(service), "%s\\*.dll", dir);
if ((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE)
HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory")
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 58987ab..ff3a53f 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2753,7 +2753,7 @@ H5T__conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
HDassert(domain[1] >= domain[0]);
length = (unsigned)(domain[1] - domain[0]) + 1;
if (src->shared->u.enumer.nmembs < 2 ||
- (double)length / src->shared->u.enumer.nmembs < (double)(1.2f)) {
+ (double)length / src->shared->u.enumer.nmembs < (double)(1.2F)) {
priv->base = domain[0];
priv->length = length;
if (NULL == (map = (int *)H5MM_malloc(length * sizeof(int))))
diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c
index 434fd43..85f36d4 100644
--- a/src/H5VLpassthru.c
+++ b/src/H5VLpassthru.c
@@ -660,16 +660,13 @@ H5VL_pass_through_info_to_str(const void *_info, char **str)
under_vol_str_len = strlen(under_vol_string);
/* Allocate space for our info */
- *str = (char *)H5allocate_memory(32 + under_vol_str_len, (hbool_t)0);
+ size_t strSize = 32 + under_vol_str_len;
+ *str = (char *)H5allocate_memory(strSize, (hbool_t)0);
assert(*str);
- /* Encode our info
- * Normally we'd use snprintf() here for a little extra safety, but that
- * call had problems on Windows until recently. So, to be as platform-independent
- * as we can, we're using sprintf() instead.
- */
- sprintf(*str, "under_vol=%u;under_info={%s}", (unsigned)under_value,
- (under_vol_string ? under_vol_string : ""));
+ /* Encode our info */
+ snprintf(*str, strSize, "under_vol=%u;under_info={%s}", (unsigned)under_value,
+ (under_vol_string ? under_vol_string : ""));
return 0;
} /* end H5VL_pass_through_info_to_str() */
diff --git a/src/H5private.h b/src/H5private.h
index de451f6..b560d62 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -232,7 +232,7 @@
*/
#define BEGIN_MPE_LOG \
if (H5_MPEinit_g) { \
- sprintf(p_event_start, "start %s", FUNC); \
+ snprintf(p_event_start, sizeof(p_event_start), "start %s", FUNC); \
if (eventa(FUNC) == -1 && eventb(FUNC) == -1) { \
const char *p_color = "red"; \
eventa(FUNC) = MPE_Log_get_event_number(); \