Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HD from strto* calls #3204

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hl/tools/h5watch/h5watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ parse_command_line(int argc, const char *const *argv)
break;

case 'w': /* --width=N */
g_display_width = (int)HDstrtol(H5_optarg, NULL, 0);
g_display_width = (int)strtol(H5_optarg, NULL, 0);
if (g_display_width < 0) {
usage(h5tools_getprogname());
leave(EXIT_FAILURE);
Expand All @@ -709,8 +709,8 @@ parse_command_line(int argc, const char *const *argv)
break;

case 'p': /* --polling=N */
/* g_polling_interval = HDstrtod(H5_optarg, NULL); */
if ((tmp = (int)HDstrtol(H5_optarg, NULL, 10)) <= 0) {
/* g_polling_interval = strtod(H5_optarg, NULL); */
if ((tmp = (int)strtol(H5_optarg, NULL, 10)) <= 0) {
usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
Expand Down
4 changes: 2 additions & 2 deletions src/H5.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ H5__debug_mask(const char *s)
} /* end if-else */
}
else if (HDisdigit(*s)) {
int fd = (int)HDstrtol(s, &rest, 0);
int fd = (int)strtol(s, &rest, 0);
H5_debug_open_stream_t *open_stream;

if ((stream = HDfdopen(fd, "w")) != NULL) {
Expand Down Expand Up @@ -889,7 +889,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
s = HDgetenv("HDF5_DISABLE_VERSION_CHECK");

if (s && HDisdigit(*s))
disable_version_check = (unsigned int)HDstrtol(s, NULL, 0);
disable_version_check = (unsigned int)strtol(s, NULL, 0);
}

/* H5_VERS_MAJOR and H5_VERS_MINOR must match */
Expand Down
2 changes: 1 addition & 1 deletion src/H5AC.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ H5AC_init(void)

s = HDgetenv("H5_COLL_API_SANITY_CHECK");
if (s && HDisdigit(*s)) {
long env_val = HDstrtol(s, NULL, 0);
long env_val = strtol(s, NULL, 0);
H5_coll_api_sanity_check_g = (0 == env_val) ? FALSE : TRUE;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ H5FD_mpio_init(void)
/* Allow MPI buf-and-file-type optimizations? */
s = HDgetenv("HDF5_MPI_OPT_TYPES");
if (s && HDisdigit(*s))
H5FD_mpi_opt_types_g = (0 == HDstrtol(s, NULL, 0)) ? FALSE : TRUE;
H5FD_mpi_opt_types_g = (0 == strtol(s, NULL, 0)) ? FALSE : TRUE;

#ifdef H5FDmpio_DEBUG
/* Clear the flag buffer */
Expand Down
12 changes: 6 additions & 6 deletions src/H5FDonion.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ H5FD__onion_parse_config_str(const char *config_str, H5FD_onion_fapl_info_t *fa)
* e.g. {revision_num: 2; page_size: 4;}
*/
if (config_str[0] != '{')
fa->revision_num = (uint64_t)HDstrtoull(config_str, NULL, 10);
fa->revision_num = (uint64_t)strtoull(config_str, NULL, 10);
else {
char *token1 = NULL, *token2 = NULL;

Expand Down Expand Up @@ -847,22 +847,22 @@ H5FD__onion_parse_config_str(const char *config_str, H5FD_onion_fapl_info_t *fa)
else if (!strcmp(token2, "H5I_INVALID_HID"))
fa->backing_fapl_id = H5I_INVALID_HID;
else
fa->backing_fapl_id = HDstrtoll(token2, NULL, 10);
fa->backing_fapl_id = strtoll(token2, NULL, 10);
}
else if (!HDstrcmp(token1, "page_size")) {
fa->page_size = (uint32_t)HDstrtoul(token2, NULL, 10);
fa->page_size = (uint32_t)strtoul(token2, NULL, 10);
}
else if (!HDstrcmp(token1, "revision_num")) {
if (!HDstrcmp(token2, "H5FD_ONION_FAPL_INFO_REVISION_ID_LATEST"))
fa->revision_num = H5FD_ONION_FAPL_INFO_REVISION_ID_LATEST;
else
fa->revision_num = (uint64_t)HDstrtoull(token2, NULL, 10);
fa->revision_num = (uint64_t)strtoull(token2, NULL, 10);
}
else if (!HDstrcmp(token1, "force_write_open")) {
fa->force_write_open = (uint8_t)HDstrtoul(token2, NULL, 10);
fa->force_write_open = (uint8_t)strtoul(token2, NULL, 10);
}
else if (!HDstrcmp(token1, "creation_flags")) {
fa->creation_flags = (uint8_t)HDstrtoul(token2, NULL, 10);
fa->creation_flags = (uint8_t)strtoul(token2, NULL, 10);
}
else if (!HDstrcmp(token1, "comment")) {
HDstrcpy(fa->comment, token2);
Expand Down
4 changes: 2 additions & 2 deletions src/H5FDs3comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,11 +955,11 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle)
*/
*end = '\0';

content_length = HDstrtoumax((const char *)start, NULL, 0);
content_length = strtoumax((const char *)start, NULL, 0);
if (UINTMAX_MAX > SIZE_MAX && content_length > SIZE_MAX)
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "content_length overflows size_t");

if (content_length == 0 || errno == ERANGE) /* errno set by HDstrtoumax*/
if (content_length == 0 || errno == ERANGE) /* errno set by strtoumax*/
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"could not convert found \"Content-Length\" response (\"%s\")",
start); /* range is null-terminated, remember */
Expand Down
10 changes: 5 additions & 5 deletions src/H5FDsubfiling/H5subfiling_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ init_subfiling(const char *base_filename, uint64_t file_id, H5FD_subfiling_param

errno = 0;

stripe_size = HDstrtoll(env_value, NULL, 0);
stripe_size = strtoll(env_value, NULL, 0);
if (ERANGE == errno)
H5_SUBFILING_SYS_GOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL,
"invalid stripe size setting for " H5FD_SUBFILING_STRIPE_SIZE);
Expand Down Expand Up @@ -987,7 +987,7 @@ init_app_topology(H5FD_subfiling_params_t *subfiling_config, MPI_Comm comm, MPI_
/* Check for an IOC-per-node value set in the environment */
if ((env_value = HDgetenv(H5FD_SUBFILING_IOC_PER_NODE))) {
errno = 0;
ioc_select_val = HDstrtol(env_value, NULL, 0);
ioc_select_val = strtol(env_value, NULL, 0);
if ((ERANGE == errno)) {
printf("invalid value '%s' for " H5FD_SUBFILING_IOC_PER_NODE "\n", env_value);
ioc_select_val = 1;
Expand All @@ -1014,7 +1014,7 @@ init_app_topology(H5FD_subfiling_params_t *subfiling_config, MPI_Comm comm, MPI_
ioc_select_val = 1;
if (ioc_sel_str) {
errno = 0;
ioc_select_val = HDstrtol(ioc_sel_str, NULL, 0);
ioc_select_val = strtol(ioc_sel_str, NULL, 0);
if ((ERANGE == errno) || (ioc_select_val <= 0)) {
printf("invalid IOC selection strategy string '%s' for strategy "
"SELECT_IOC_EVERY_NTH_RANK; defaulting to SELECT_IOC_ONE_PER_NODE\n",
Expand Down Expand Up @@ -1050,7 +1050,7 @@ init_app_topology(H5FD_subfiling_params_t *subfiling_config, MPI_Comm comm, MPI_
ioc_select_val = 1;
if (ioc_sel_str) {
errno = 0;
ioc_select_val = HDstrtol(ioc_sel_str, NULL, 0);
ioc_select_val = strtol(ioc_sel_str, NULL, 0);
if ((ERANGE == errno) || (ioc_select_val <= 0)) {
printf("invalid IOC selection strategy string '%s' for strategy SELECT_IOC_TOTAL; "
"defaulting to SELECT_IOC_ONE_PER_NODE\n",
Expand Down Expand Up @@ -1213,7 +1213,7 @@ get_ioc_selection_criteria_from_env(H5FD_subfiling_ioc_select_t *ioc_selection_t
*opt_value++ = '\0';

errno = 0;
check_value = HDstrtol(env_value, NULL, 0);
check_value = strtol(env_value, NULL, 0);

if (errno == ERANGE)
H5_SUBFILING_SYS_GOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL,
Expand Down
18 changes: 0 additions & 18 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -1116,30 +1116,12 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDstrstr
#define HDstrstr(X, Y) strstr(X, Y)
#endif
#ifndef HDstrtod
#define HDstrtod(S, R) strtod(S, R)
#endif
#ifndef HDstrtok
#define HDstrtok(X, Y) strtok(X, Y)
#endif
#ifndef HDstrtok_r
#define HDstrtok_r(X, Y, Z) strtok_r(X, Y, Z)
#endif
#ifndef HDstrtol
#define HDstrtol(S, R, N) strtol(S, R, N)
#endif
#ifndef HDstrtoll
#define HDstrtoll(S, R, N) strtoll(S, R, N)
#endif
#ifndef HDstrtoul
#define HDstrtoul(S, R, N) strtoul(S, R, N)
#endif
#ifndef HDstrtoull
#define HDstrtoull(S, R, N) strtoull(S, R, N)
#endif
#ifndef HDstrtoumax
#define HDstrtoumax(S, R, N) strtoumax(S, R, N)
#endif
#ifndef HDsymlink
#define HDsymlink(F1, F2) symlink(F1, F2)
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/H5trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap)
char *rest;

if ('a' == type[1]) {
asize_idx = (int)HDstrtol(type + 2, &rest, 10);
asize_idx = (int)strtol(type + 2, &rest, 10);
assert(0 <= asize_idx && asize_idx < (int)NELMTS(asize));
assert(']' == *rest);
type = rest + 1;
Expand Down
6 changes: 3 additions & 3 deletions test/big.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ reader(char *filename, hid_t fapl)
while (HDfgets(ln, (int)sizeof(ln), script)) {
if ('#' != ln[0])
break;
i = (int)HDstrtol(ln + 1, &s, 10);
hs_offset[0] = HDstrtoull(s, NULL, 0);
i = (int)strtol(ln + 1, &s, 10);
hs_offset[0] = strtoull(s, NULL, 0);
fprintf(stdout, "#%03d 0x%016" PRIxHSIZE "%47s", i, hs_offset[0], "");
HDfflush(stdout);

Expand Down Expand Up @@ -741,7 +741,7 @@ main(int ac, char **av)
ac--;
av++;
if (ac > 0) {
family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0);
family_size_def = (hsize_t)strtoull(*av, NULL, 0);
}
else {
printf("***Missing fsize value***\n");
Expand Down
2 changes: 1 addition & 1 deletion test/testframe.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ TestAlarmOn(void)

/* Get the alarm value from the environment variable, if set */
if (env_val != NULL)
alarm_sec = (unsigned)HDstrtoul(env_val, (char **)NULL, 10);
alarm_sec = (unsigned)strtoul(env_val, (char **)NULL, 10);

/* Set the number of seconds before alarm goes off */
HDalarm((unsigned)alarm_sec);
Expand Down
6 changes: 3 additions & 3 deletions test/use_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ parse_option(int argc, char *const argv[], options_t *opts)
} /* end switch (reader/writer-only mode toggle) */
break;
case 'n': /* number of planes to write/read */
if ((opts->nplanes = HDstrtoul(optarg, NULL, 0)) <= 0) {
if ((opts->nplanes = strtoul(optarg, NULL, 0)) <= 0) {
fprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg);
usage(opts->progname);
Hgoto_error(-1);
Expand All @@ -110,15 +110,15 @@ parse_option(int argc, char *const argv[], options_t *opts)
opts->use_swmr = (hbool_t)use_swmr;
break;
case 'y': /* Number of planes per chunk */
if ((opts->chunkplanes = HDstrtoul(optarg, NULL, 0)) <= 0) {
if ((opts->chunkplanes = strtoul(optarg, NULL, 0)) <= 0) {
fprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n",
optarg);
usage(opts->progname);
Hgoto_error(-1);
}
break;
case 'z': /* size of chunk=(z,z) */
if ((opts->chunksize = HDstrtoull(optarg, NULL, 0)) <= 0) {
if ((opts->chunksize = strtoull(optarg, NULL, 0)) <= 0) {
fprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg);
usage(opts->progname);
Hgoto_error(-1);
Expand Down
4 changes: 2 additions & 2 deletions testpar/t_subfiling_vfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,13 +2073,13 @@ parse_subfiling_env_vars(void)
char *env_value;

if (NULL != (env_value = HDgetenv(H5FD_SUBFILING_STRIPE_SIZE))) {
stripe_size_g = HDstrtoll(env_value, NULL, 0);
stripe_size_g = strtoll(env_value, NULL, 0);
if ((ERANGE == errno) || (stripe_size_g <= 0))
stripe_size_g = -1;
}

if (NULL != (env_value = HDgetenv(H5FD_SUBFILING_IOC_PER_NODE))) {
ioc_per_node_g = HDstrtol(env_value, NULL, 0);
ioc_per_node_g = strtol(env_value, NULL, 0);
if ((ERANGE == errno) || (ioc_per_node_g <= 0))
ioc_per_node_g = -1;
else if (ioc_per_node_g * num_nodes_g > mpi_size)
Expand Down
6 changes: 3 additions & 3 deletions tools/lib/h5tools_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ parse_hsize_list(const char *h_list, subset_d *d)
for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
if (HDisdigit(*ptr)) {
/* we should have an integer now */
p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0);
p_list[i++] = (hsize_t)strtoull(ptr, NULL, 0);

while (HDisdigit(*ptr))
/* scroll to end of integer */
Expand Down Expand Up @@ -999,7 +999,7 @@ h5tools_getenv_update_hyperslab_bufsize(void)
/* check if environment variable is set for the hyperslab buffer size */
if (NULL != (env_str = HDgetenv("H5TOOLS_BUFSIZE"))) {
errno = 0;
hyperslab_bufsize_mb = HDstrtol(env_str, (char **)NULL, 10);
hyperslab_bufsize_mb = strtol(env_str, (char **)NULL, 10);
if (errno != 0 || hyperslab_bufsize_mb <= 0)
H5TOOLS_GOTO_ERROR(FAIL, "hyperslab buffer size failed");

Expand Down Expand Up @@ -1283,7 +1283,7 @@ h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, H5FD_hdfs_fapl_t
HDstrncpy(fapl_config_out->user_name, (const char *)props[3], HDstrlen(props[3]));
}
if (HDstrncmp(props[4], "", 1)) {
k = HDstrtoul((const char *)props[4], NULL, 0);
k = strtoul((const char *)props[4], NULL, 0);
if (errno == ERANGE)
H5TOOLS_GOTO_ERROR(FAIL, "supposed buffersize number wasn't");
fapl_config_out->stream_buffer_size = (int32_t)k;
Expand Down
6 changes: 3 additions & 3 deletions tools/src/h5diff/h5diff_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const
usage();
h5diff_exit(EXIT_FAILURE);
}
opts->count = HDstrtoull(H5_optarg, NULL, 0);
opts->count = strtoull(H5_optarg, NULL, 0);
break;

case 'N':
Expand Down Expand Up @@ -390,7 +390,7 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const
if (opts->vfd_info[0].u.name && !HDstrcmp(opts->vfd_info[0].u.name, "onion")) {
if (opts->vfd_info[0].info) {
errno = 0;
onion_fa_g_1.revision_num = HDstrtoull(opts->vfd_info[0].info, NULL, 10);
onion_fa_g_1.revision_num = strtoull(opts->vfd_info[0].info, NULL, 10);
if (errno == ERANGE) {
printf("Invalid onion revision specified for file 1\n");
usage();
Expand All @@ -407,7 +407,7 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const
if (opts->vfd_info[1].u.name && !HDstrcmp(opts->vfd_info[1].u.name, "onion")) {
if (opts->vfd_info[1].info) {
errno = 0;
onion_fa_g_2.revision_num = HDstrtoull(opts->vfd_info[1].info, NULL, 10);
onion_fa_g_2.revision_num = strtoull(opts->vfd_info[1].info, NULL, 10);
if (errno == ERANGE) {
printf("Invalid onion revision specified for file 2\n");
usage();
Expand Down
2 changes: 1 addition & 1 deletion tools/src/h5dump/h5dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ parse_command_line(int argc, const char *const *argv)
get_onion_revision_count = TRUE;
else {
errno = 0;
onion_fa_g.revision_num = HDstrtoull(vfd_info_g.info, NULL, 10);
onion_fa_g.revision_num = strtoull(vfd_info_g.info, NULL, 10);
if (errno == ERANGE) {
printf("Invalid onion revision specified\n");
goto error;
Expand Down
Loading