Skip to content

Commit

Permalink
Replaced last sprintf with snprintf (#4007)
Browse files Browse the repository at this point in the history
* Replaced last sprintf with snprintf

To have the size of the buffer, it was required to change a function signature, and change all users of it.

In most cases, determining the buffer size wasn't  trivial and so SIZE_MAX is passed. But at least this improves the infrastructure. Someone can later figure out the correct sizes.
  • Loading branch information
seanm authored Feb 20, 2024
1 parent f73da83 commit 7aed6ab
Show file tree
Hide file tree
Showing 21 changed files with 79 additions and 48 deletions.
6 changes: 4 additions & 2 deletions src/H5Oainfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__ainfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__ainfo_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__ainfo_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__ainfo_copy(const void *_mesg, void *_dest);
static size_t H5O__ainfo_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__ainfo_free(void *_mesg);
Expand Down Expand Up @@ -175,7 +176,8 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS
*-------------------------------------------------------------------------
*/
static herr_t
H5O__ainfo_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__ainfo_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg)
{
const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg;
unsigned char flags; /* Flags for encoding attribute info */
Expand Down
4 changes: 2 additions & 2 deletions src/H5Oattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ H5O__attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += name_len;

/* encode the attribute datatype */
if ((H5O_MSG_DTYPE->encode)(f, false, p, attr->shared->dt) < 0)
if ((H5O_MSG_DTYPE->encode)(f, false, SIZE_MAX, p, attr->shared->dt) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute datatype");

if (attr->shared->version < H5O_ATTR_VERSION_2) {
Expand All @@ -391,7 +391,7 @@ H5O__attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += attr->shared->dt_size;

/* encode the attribute dataspace */
if ((H5O_MSG_SDSPACE->encode)(f, false, p, &(attr->shared->ds->extent)) < 0)
if ((H5O_MSG_SDSPACE->encode)(f, false, SIZE_MAX, p, &(attr->shared->ds->extent)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute dataspace");

if (attr->shared->version < H5O_ATTR_VERSION_2) {
Expand Down
7 changes: 4 additions & 3 deletions src/H5Obogus.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__bogus_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__bogus_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__bogus_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static size_t H5O__bogus_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__bogus_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth);

Expand Down Expand Up @@ -142,8 +143,8 @@ H5O__bogus_decode(H5F_t *f, H5O_t H5_ATTR_NDEBUG_UNUSED *open_oh, unsigned H5_AT
*-------------------------------------------------------------------------
*/
static herr_t
H5O__bogus_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p,
const void H5_ATTR_UNUSED *mesg)
H5O__bogus_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size,
uint8_t *p, const void H5_ATTR_UNUSED *mesg)
{
FUNC_ENTER_PACKAGE_NOERR

Expand Down
6 changes: 4 additions & 2 deletions src/H5Obtreek.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

static void *H5O__btreek_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__btreek_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__btreek_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__btreek_copy(const void *_mesg, void *_dest);
static size_t H5O__btreek_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__btreek_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth);
Expand Down Expand Up @@ -120,7 +121,8 @@ H5O__btreek_decode(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh
*-------------------------------------------------------------------------
*/
static herr_t
H5O__btreek_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__btreek_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size,
uint8_t *p, const void *_mesg)
{
const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg;

Expand Down
6 changes: 4 additions & 2 deletions src/H5Ocache_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
/* Callbacks for message class */
static void *H5O__mdci_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size,
const uint8_t *p);
static herr_t H5O__mdci_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__mdci_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__mdci_copy(const void *_mesg, void *_dest);
static size_t H5O__mdci_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__mdci_free(void *mesg);
Expand Down Expand Up @@ -135,7 +136,8 @@ H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE
*-------------------------------------------------------------------------
*/
static herr_t
H5O__mdci_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__mdci_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg)
{
const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg;

Expand Down
6 changes: 4 additions & 2 deletions src/H5Ocont.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__cont_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size,
const uint8_t *p);
static herr_t H5O__cont_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__cont_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static size_t H5O__cont_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__cont_free(void *mesg);
static herr_t H5O__cont_delete(H5F_t *f, H5O_t *open_oh, void *_mesg);
Expand Down Expand Up @@ -122,7 +123,8 @@ H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE
*-------------------------------------------------------------------------
*/
static herr_t
H5O__cont_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__cont_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg)
{
const H5O_cont_t *cont = (const H5O_cont_t *)_mesg;

Expand Down
7 changes: 4 additions & 3 deletions src/H5Odrvinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

static void *H5O__drvinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__drvinfo_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__drvinfo_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__drvinfo_copy(const void *_mesg, void *_dest);
static size_t H5O__drvinfo_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__drvinfo_reset(void *_mesg);
Expand Down Expand Up @@ -135,8 +136,8 @@ H5O__drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh,
*-------------------------------------------------------------------------
*/
static herr_t
H5O__drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p,
const void *_mesg)
H5O__drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size,
uint8_t *p, const void *_mesg)
{
const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg;

Expand Down
6 changes: 4 additions & 2 deletions src/H5Oefl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__efl_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size,
const uint8_t *p);
static herr_t H5O__efl_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__efl_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__efl_copy(const void *_mesg, void *_dest);
static size_t H5O__efl_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__efl_reset(void *_mesg);
Expand Down Expand Up @@ -197,7 +198,8 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED
*-------------------------------------------------------------------------
*/
static herr_t
H5O__efl_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__efl_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg)
{
const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
size_t u; /* Local index variable */
Expand Down
6 changes: 4 additions & 2 deletions src/H5Ofsinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__fsinfo_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__fsinfo_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__fsinfo_copy(const void *_mesg, void *_dest);
static size_t H5O__fsinfo_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__fsinfo_free(void *mesg);
Expand Down Expand Up @@ -222,7 +223,8 @@ H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU
*-------------------------------------------------------------------------
*/
static herr_t
H5O__fsinfo_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__fsinfo_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg)
{
const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg;
H5F_mem_page_t ptype; /* Memory type for iteration */
Expand Down
6 changes: 4 additions & 2 deletions src/H5Oginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__ginfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__ginfo_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__ginfo_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__ginfo_copy(const void *_mesg, void *_dest);
static size_t H5O__ginfo_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__ginfo_free(void *_mesg);
Expand Down Expand Up @@ -158,7 +159,8 @@ H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign
*-------------------------------------------------------------------------
*/
static herr_t
H5O__ginfo_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__ginfo_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size,
uint8_t *p, const void *_mesg)
{
const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg;
unsigned char flags = 0; /* Flags for encoding group info */
Expand Down
6 changes: 4 additions & 2 deletions src/H5Olayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__layout_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__layout_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__layout_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__layout_copy(const void *_mesg, void *_dest);
static size_t H5O__layout_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__layout_reset(void *_mesg);
Expand Down Expand Up @@ -794,7 +795,8 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU
*-------------------------------------------------------------------------
*/
static herr_t
H5O__layout_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__layout_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg)
{
const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg;
unsigned u;
Expand Down
6 changes: 4 additions & 2 deletions src/H5Olinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__linfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__linfo_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__linfo_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__linfo_copy(const void *_mesg, void *_dest);
static size_t H5O__linfo_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__linfo_free(void *_mesg);
Expand Down Expand Up @@ -183,7 +184,8 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS
*-------------------------------------------------------------------------
*/
static herr_t
H5O__linfo_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__linfo_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg)
{
const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg;
unsigned char index_flags; /* Flags for encoding link index info */
Expand Down
6 changes: 4 additions & 2 deletions src/H5Olink.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__link_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size,
const uint8_t *p);
static herr_t H5O__link_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__link_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__link_copy(const void *_mesg, void *_dest);
static size_t H5O__link_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__link_reset(void *_mesg);
Expand Down Expand Up @@ -289,7 +290,8 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE
*-------------------------------------------------------------------------
*/
static herr_t
H5O__link_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__link_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg)
{
const H5O_link_t *lnk = (const H5O_link_t *)_mesg;
uint64_t len; /* Length of a string in the message */
Expand Down
4 changes: 2 additions & 2 deletions src/H5Omessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ H5O_msg_encode(H5F_t *f, unsigned type_id, bool disable_shared, unsigned char *b
assert(type);

/* Encode */
if ((type->encode)(f, disable_shared, buf, mesg) < 0)
if ((type->encode)(f, disable_shared, SIZE_MAX, buf, mesg) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message");

done:
Expand Down Expand Up @@ -1972,7 +1972,7 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg)
}
#endif /* NDEBUG */
assert(mesg->type->encode);
if ((mesg->type->encode)(f, false, mesg->raw, mesg->native) < 0)
if ((mesg->type->encode)(f, false, mesg->raw_size, mesg->raw, mesg->native) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message");
} /* end if */

Expand Down
16 changes: 9 additions & 7 deletions src/H5Omtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

static void *H5O__mtime_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__mtime_new_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__mtime_new_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static size_t H5O__mtime_new_size(const H5F_t *f, bool disable_shared, const void *_mesg);

static void *H5O__mtime_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
size_t p_size, const uint8_t *p);
static herr_t H5O__mtime_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__mtime_encode(H5F_t *f, bool disable_shared, size_t p_size, uint8_t *p, const void *_mesg);
static void *H5O__mtime_copy(const void *_mesg, void *_dest);
static size_t H5O__mtime_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__mtime_free(void *_mesg);
Expand Down Expand Up @@ -221,8 +222,8 @@ H5O__mtime_decode(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh,
*-------------------------------------------------------------------------
*/
static herr_t
H5O__mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p,
const void *_mesg)
H5O__mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared,
size_t H5_ATTR_UNUSED p_size, uint8_t *p, const void *_mesg)
{
const time_t *mesg = (const time_t *)_mesg;

Expand Down Expand Up @@ -257,7 +258,8 @@ H5O__mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_share
*-------------------------------------------------------------------------
*/
static herr_t
H5O__mtime_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__mtime_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, size_t p_size, uint8_t *p,
const void *_mesg)
{
const time_t *mesg = (const time_t *)_mesg;
struct tm *tm;
Expand All @@ -271,8 +273,8 @@ H5O__mtime_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, u

/* encode */
tm = HDgmtime(mesg);
sprintf((char *)p, "%04d%02d%02d%02d%02d%02d", 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
snprintf((char *)p, p_size, "%04d%02d%02d%02d%02d%02d", 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);

FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O__mtime_encode() */
Expand Down
6 changes: 4 additions & 2 deletions src/H5Oname.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O__name_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size,
const uint8_t *p);
static herr_t H5O__name_encode(H5F_t *f, bool disable_shared, uint8_t *p, const void *_mesg);
static herr_t H5O__name_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p,
const void *_mesg);
static void *H5O__name_copy(const void *_mesg, void *_dest);
static size_t H5O__name_size(const H5F_t *f, bool disable_shared, const void *_mesg);
static herr_t H5O__name_reset(void *_mesg);
Expand Down Expand Up @@ -110,7 +111,8 @@ H5O__name_decode(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh,
*-------------------------------------------------------------------------
*/
static herr_t
H5O__name_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
H5O__name_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size,
uint8_t *p, const void *_mesg)
{
const H5O_name_t *mesg = (const H5O_name_t *)_mesg;

Expand Down
Loading

0 comments on commit 7aed6ab

Please sign in to comment.