Fix JNI bug, fix warnings noticed in MSVC CI, be modern & portable (#1480)

This commit is contained in:
David Young 2022-03-10 13:54:20 -06:00 committed by GitHub
parent b9470be379
commit 1fb3743f04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 12 deletions

View File

@ -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");

View File

@ -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)))

View File

@ -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];

View File

@ -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