From c03ee563f46013d22f36a1895664a9ba876558e9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 27 Apr 2020 08:50:27 -0700 Subject: Further updates to the tools warnings fixes from code review. --- tools/src/h5dump/h5dump_xml.c | 10 +++++++--- tools/test/misc/h5clear_gentest.c | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index bd822bc..07cff6a 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -738,9 +738,9 @@ xml_escape_the_string(const char *str, int slen) size_t extra; size_t len; size_t i; - const char *cp; - char *ncp; - char *rcp; + const char *cp = NULL; + char *ncp = NULL; + char *rcp = NULL; size_t ncp_len; if (!str) @@ -793,18 +793,22 @@ xml_escape_the_string(const char *str, int slen) } else if (*cp == '\'') { HDstrncpy(ncp, apos, ncp_len); + ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(apos); } else if (*cp == '<') { HDstrncpy(ncp, lt, ncp_len); + ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(lt); } else if (*cp == '>') { HDstrncpy(ncp, gt, ncp_len); + ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(gt); } else if (*cp == '&') { HDstrncpy(ncp, amp, ncp_len); + ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(amp); } else { diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c index 06ba473..8d6883c 100644 --- a/tools/test/misc/h5clear_gentest.c +++ b/tools/test/misc/h5clear_gentest.c @@ -62,6 +62,7 @@ gen_cache_image_file(const char *fname) hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ hsize_t dims[2]; /* Dimension sizes */ hsize_t chunks[2]; /* Chunked dimension sizes */ + int i, j; /* Local index variables */ int **buf = NULL; /* Buffer for data to write */ H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ { H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, @@ -72,7 +73,9 @@ gen_cache_image_file(const char *fname) H5TEST_ALLOCATE_2D_ARRAY(buf, int, 50, 100); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, 50, 100); + for(i = 0; i < 50; i++) + for(j = 0; j < 100; j++) + buf[i][j] = i * j; /* Create a copy of file access property list */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) -- cgit v0.12