summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2022-03-10 19:54:20 (GMT)
committerGitHub <noreply@github.com>2022-03-10 19:54:20 (GMT)
commit1fb3743f04df101c7245ce045b67d371d462fd70 (patch)
treeb7336b3d48e8016e3967b9175223b4230149bd9c
parentb9470be379354af209daf8418b6c571dde99e776 (diff)
downloadhdf5-1fb3743f04df101c7245ce045b67d371d462fd70.zip
hdf5-1fb3743f04df101c7245ce045b67d371d462fd70.tar.gz
hdf5-1fb3743f04df101c7245ce045b67d371d462fd70.tar.bz2
Fix JNI bug, fix warnings noticed in MSVC CI, be modern & portable (#1480)
-rw-r--r--java/src/jni/h5util.c8
-rw-r--r--src/H5VMprivate.h4
-rw-r--r--src/H5system.c4
-rw-r--r--test/external.c7
4 files changed, 11 insertions, 12 deletions
diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c
index 5a01dc9..2de5d87 100644
--- a/java/src/jni/h5util.c
+++ b/java/src/jni/h5util.c
@@ -813,7 +813,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i
if (NULL == (this_str = (char *)HDmalloc(this_len)))
H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
- if (HDsnprintf(this_str, "%g", this_len, tmp_double) < 0)
+ if (HDsnprintf(this_str, this_len, "%g", tmp_double) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure");
break;
@@ -1160,11 +1160,11 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i
H5Otoken_to_str(tid, &oi.token, &token_str);
- size_t this_len = 64 + strlen(token_str) + 1;
- if (NULL == (this_str = (char *)HDmalloc(this_len)))
+ size_t that_len = 64 + strlen(token_str) + 1;
+ if (NULL == (this_str = HDmalloc(that_len)))
H5_OUT_OF_MEMORY_ERROR(
ENVONLY, "h5str_sprintf: failed to allocate string buffer");
- if (HDsnprintf(this_str, this_len, "%lu:%s", oi.fileno, token_str) <
+ if (HDsnprintf(this_str, that_len, "%lu:%s", oi.fileno, token_str) <
0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure");
diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h
index 0d3bd0f..e773bae 100644
--- a/src/H5VMprivate.h
+++ b/src/H5VMprivate.h
@@ -393,8 +393,8 @@ static const unsigned char LogTable256[] = {
static inline unsigned H5_ATTR_UNUSED
H5VM_log2_gen(uint64_t n)
{
- unsigned r; /* r will be log2(n) */
- register unsigned int t, tt, ttt; /* temporaries */
+ unsigned r; /* r will be log2(n) */
+ unsigned int t, tt, ttt; /* temporaries */
if ((ttt = (unsigned)(n >> 32)))
if ((tt = (unsigned)(n >> 48)))
diff --git a/src/H5system.c b/src/H5system.c
index ee9077e..a369e3d 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -862,7 +862,7 @@ H5_nanosleep(uint64_t nanosec)
#else
- const uint64_t nanosec_per_sec = 1000 * 1000 * 1000;
+ const uint64_t nanosec_per_sec = 1000 * 1000L * 1000;
struct timespec sleeptime; /* Struct to hold time to sleep */
/* Set up time to sleep
@@ -1033,7 +1033,7 @@ H5_get_option(int argc, const char *const *argv, const char *opts, const struct
HDfree(arg);
}
else {
- register char *cp; /* pointer into current token */
+ char *cp; /* pointer into current token */
/* short command line option */
optchar = argv[H5_optind][sp];
diff --git a/test/external.c b/test/external.c
index 11185b3..bb86cde 100644
--- a/test/external.c
+++ b/test/external.c
@@ -166,8 +166,7 @@ test_non_extendible(hid_t file)
if (file_size != (max_size[0] * sizeof(int))) {
H5_FAILED();
HDputs(" Wrong file size.");
- HDprintf(" got: %lu\n ans: %lu\n", (unsigned long)file_size,
- (unsigned long)max_size[0] * sizeof(int));
+ HDprintf(" got: %" PRIuHSIZE "\n ans: %" PRIuHSIZE "\n", file_size, max_size[0] * sizeof(int));
goto error;
}
@@ -986,11 +985,11 @@ test_path_absolute(hid_t fapl)
if (NULL == HDgetcwd(cwdpath, sizeof(cwdpath)))
TEST_ERROR
for (i = 0; i < N_EXT_FILES; i++) {
- HDsnprintf(filename, sizeof(filename), "%s%sextern_%dr.raw", cwdpath, H5_DIR_SEPS, (int)i + 1);
+ HDsnprintf(filename, sizeof(filename), "%s%sextern_%zur.raw", cwdpath, H5_DIR_SEPS, i + 1);
#if defined(H5_HAVE_WINDOW_PATH)
/* For windows, test path-absolute case (\dir\file.raw) for the second file */
if (i == 1)
- HDsnprintf(filename, sizeof(filename), "%s%sextern_%dr.raw", cwdpath + 2, H5_DIR_SEPS, i + 1);
+ HDsnprintf(filename, sizeof(filename), "%s%sextern_%zur.raw", cwdpath + 2, H5_DIR_SEPS, i + 1);
#endif
if (H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0)
FAIL_STACK_ERROR