diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2022-06-30 14:47:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 14:47:34 (GMT) |
commit | 552833213c979e9df3e03cc6ea3a2ec1f3847121 (patch) | |
tree | 5c294783f39e2f0a80c01101fbe79a5a4a29c9bd /src | |
parent | 72db748dd996b463daf7896d287417c97149c5ac (diff) | |
download | hdf5-552833213c979e9df3e03cc6ea3a2ec1f3847121.zip hdf5-552833213c979e9df3e03cc6ea3a2ec1f3847121.tar.gz hdf5-552833213c979e9df3e03cc6ea3a2ec1f3847121.tar.bz2 |
Fix for gcc-12 warning about string truncation in H5Opline.c (#1835)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Opline.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/H5Opline.c b/src/H5Opline.c index 7f73801..5618dce 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -639,7 +639,6 @@ static herr_t H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int indent, int fwidth) { const H5O_pline_t *pline = (const H5O_pline_t *)mesg; - size_t i, j; FUNC_ENTER_PACKAGE_NOERR @@ -654,10 +653,15 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int in pline->nalloc); /* Loop over all the filters */ - for (i = 0; i < pline->nused; i++) { - char name[32]; + for (size_t i = 0; i < pline->nused; i++) { + /* 19 characters for text + 20 characters for largest 64-bit size_t + + * terminal NUL = 40 characters. + */ + char name[64]; + HDmemset(name, 0, 64); HDsnprintf(name, sizeof(name), "Filter at position %zu", i); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, name); HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3), "Filter identification:", (unsigned)(pline->filter[i].id)); @@ -672,14 +676,14 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int in "Num CD values:", pline->filter[i].cd_nelmts); /* Filter parameters */ - for (j = 0; j < pline->filter[i].cd_nelmts; j++) { + for (size_t j = 0; j < pline->filter[i].cd_nelmts; j++) { char field_name[32]; HDsnprintf(field_name, sizeof(field_name), "CD value %lu", (unsigned long)j); HDfprintf(stream, "%*s%-*s %u\n", indent + 6, "", MAX(0, fwidth - 6), field_name, pline->filter[i].cd_values[j]); - } /* end for */ - } /* end for */ + } + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__pline_debug() */ |