diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2021-03-10 00:19:13 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2021-03-10 00:19:13 (GMT) |
commit | 9aa3b40b9e3762de4773cd68ccd51057b5a17965 (patch) | |
tree | c9ee32e16d8d270f8d2f015221814b9c531cf194 | |
parent | d5b5f022cde42cfcf2ca4c179511966503e97191 (diff) | |
download | hdf5-9aa3b40b9e3762de4773cd68ccd51057b5a17965.zip hdf5-9aa3b40b9e3762de4773cd68ccd51057b5a17965.tar.gz hdf5-9aa3b40b9e3762de4773cd68ccd51057b5a17965.tar.bz2 |
Removes err.h cruft from genall5.c and vfd_swmr_common.c
-rw-r--r-- | test/genall5.c | 27 | ||||
-rw-r--r-- | test/vfd_swmr_common.c | 70 |
2 files changed, 55 insertions, 42 deletions
diff --git a/test/genall5.c b/test/genall5.c index 2874b59..904a912 100644 --- a/test/genall5.c +++ b/test/genall5.c @@ -19,8 +19,6 @@ * of the same name. */ -#include <err.h> - #include "cache_common.h" #include "vfd_swmr_common.h" /* for below_speed_limit() */ #include "genall5.h" @@ -2698,17 +2696,18 @@ random_pause(unsigned int max_pause_msecs) if (max_pause_msecs == 0) return; - nsecs_per_msec = 1 + (uint64_t)random() % (1000 * 1000); + nsecs_per_msec = 1 + (uint64_t)HDrandom() % (1000 * 1000); nsecs = max_pause_msecs * nsecs_per_msec; delay.tv_sec = (time_t)(nsecs / nsecs_per_sec); delay.tv_nsec = (long)(nsecs % nsecs_per_sec); for (;;) { - if (nanosleep(&delay, &delay) == 0) + if (HDnanosleep(&delay, &delay) == 0) break; if (errno == EINTR) continue; - errx(EXIT_FAILURE, "%s: nanosleep", __func__); + HDfprintf(stderr, "%s: nanosleep", __func__); + HDexit(EXIT_FAILURE); } } @@ -2720,7 +2719,7 @@ random_pause(unsigned int max_pause_msecs) * Return true if all tests pass, false if any test fails. */ -static bool +static hbool_t tend_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, zoo_config_t config, const phase_t *phase, size_t nphases) { @@ -2728,21 +2727,21 @@ tend_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, int i, nwritten; size_t j; char *leafp; - bool ok = true; + hbool_t ok = TRUE; - nwritten = snprintf(full_path, sizeof(full_path), "%s/*", base_path); + nwritten = HDsnprintf(full_path, sizeof(full_path), "%s/*", base_path); if (nwritten < 0 || (size_t)nwritten >= sizeof(full_path)) { failure_mssg = "tend_zoo: snprintf failed"; - return false; + return FALSE; } - if ((leafp = strrchr(full_path, '*')) == NULL) { + if ((leafp = HDstrrchr(full_path, '*')) == NULL) { failure_mssg = "tend_zoo: strrchr failed"; - return false; + return FALSE; } for (i = 0; ok; i++) { - assert('A' + i <= 'Z'); + HDassert('A' + i <= 'Z'); *leafp = (char)('A' + i); for (j = 0; j < nphases; j++) { if (!create_or_validate_selection(fid, full_path, i, config, @@ -2755,12 +2754,12 @@ tend_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, } out: if (!ok) { - if (strcmp(failure_mssg, last_failure_mssg) != 0) + if (HDstrcmp(failure_mssg, last_failure_mssg) != 0) *lastmsgtime = (struct timespec){.tv_sec = 0, .tv_nsec = 0}; if (below_speed_limit(lastmsgtime, &config.msgival)) { last_failure_mssg = failure_mssg; - warnx("%s: %s", __func__, failure_mssg); + HDfprintf(stderr, "%s: %s", __func__, failure_mssg); } } return ok; diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c index 6d4e464..82d3517 100644 --- a/test/vfd_swmr_common.c +++ b/test/vfd_swmr_common.c @@ -25,10 +25,10 @@ #ifndef H5_HAVE_WIN32_API -#include <err.h> - -/* Only need the pthread solution if sigtimedwait(2) isn't available */ -#ifndef H5_HAVE_SIGTIMEDWAIT +/* Only need the pthread solution if sigtimedwait(2) isn't available. + * There's currently no Windows solution, so ignore that for now. + */ +#if !defined(H5_HAVE_SIGTIMEDWAIT) && !defined(H5_HAVE_WIN32_API) #include <pthread.h> #endif @@ -83,13 +83,15 @@ evsnprintf(char *buf, size_t bufsz, const char *fmt, va_list ap) { int rc; - rc = vsnprintf(buf, bufsz, fmt, ap); + rc = HDvsnprintf(buf, bufsz, fmt, ap); if (rc < 0) { - err(EXIT_FAILURE, "%s: vsnprintf", __func__); + HDfprintf(stderr, "%s: HDvsnprintf", __func__); + HDexit(EXIT_FAILURE); } else if ((size_t)rc >= bufsz) { - errx(EXIT_FAILURE, "%s: buffer too small", __func__); + HDfprintf(stderr, "%s: buffer too small", __func__); + HDexit(EXIT_FAILURE); } } @@ -101,9 +103,9 @@ esnprintf(char *buf, size_t bufsz, const char *fmt, ...) { va_list ap; - va_start(ap, fmt); + HDva_start(ap, fmt); evsnprintf(buf, bufsz, fmt, ap); - va_end(ap); + HDva_end(ap); } void @@ -114,9 +116,9 @@ dbgf(int level, const char *fmt, ...) if (verbosity < level) return; - va_start(ap, fmt); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); + HDva_start(ap, fmt); + (void)HDvfprintf(stderr, fmt, ap); + HDva_end(ap); } /* Disable HDF5 error-stack printing and return the previous state @@ -159,20 +161,24 @@ block_signals(sigset_t *oldset) sigset_t fullset; if (sigfillset(&fullset) == -1) { - err(EXIT_FAILURE, "%s.%d: could not initialize signal masks", - __func__, __LINE__); + HDfprintf(stderr, "%s.%d: could not initialize signal masks", __func__, __LINE__); + HDexit(EXIT_FAILURE); } - if (sigprocmask(SIG_BLOCK, &fullset, oldset) == -1) - err(EXIT_FAILURE, "%s.%d: sigprocmask", __func__, __LINE__); + if (sigprocmask(SIG_BLOCK, &fullset, oldset) == -1) { + HDfprintf(stderr, "%s.%d: sigprocmask", __func__, __LINE__); + HDexit(EXIT_FAILURE); + } } /* Restore the signal mask in `oldset`. */ void restore_signals(sigset_t *oldset) { - if (sigprocmask(SIG_SETMASK, oldset, NULL) == -1) - err(EXIT_FAILURE, "%s.%d: sigprocmask", __func__, __LINE__); + if (sigprocmask(SIG_SETMASK, oldset, NULL) == -1) { + HDfprintf(stderr, "%s.%d: sigprocmask", __func__, __LINE__); + HDexit(EXIT_FAILURE); + } } #if 0 @@ -192,7 +198,7 @@ strsignal(int signum) } #endif -#ifndef H5_HAVE_SIGTIMEDWAIT +#if !defined(H5_HAVE_SIGTIMEDWAIT) && !defined(H5_HAVE_WIN32_API) typedef struct timer_params_t { struct timespec *tick; @@ -239,7 +245,7 @@ timer_function(void *arg) return NULL; } -#endif /* H5_HAVE_SIGTIMEDWAIT */ +#endif /* !defined(H5_HAVE_SIGTIMEDWAIT) && !defined(H5_HAVE_WIN32_API) */ /* Wait for any signal to occur and then return. Wake periodically * during the wait to perform API calls: in this way, the @@ -260,8 +266,10 @@ await_signal(hid_t fid) /* Avoid deadlock: flush the file before waiting for the reader's * message. */ - if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) - errx(EXIT_FAILURE, "%s: H5Fflush failed", __func__); + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { + HDfprintf(stderr, "%s: H5Fflush failed", __func__); + HDexit(EXIT_FAILURE); + } dbgf(1, "waiting for signal\n"); @@ -290,8 +298,10 @@ await_signal(hid_t fid) pthread_mutex_unlock(&timer_mutex); pthread_join(timer, NULL); } - else - err(EXIT_FAILURE, "%s: sigwait", __func__); + else { + HDfprintf(stderr, "%s: sigwait", __func__); + HDexit(EXIT_FAILURE); + } } #else for (;;) { @@ -299,10 +309,11 @@ await_signal(hid_t fid) const int rc = sigtimedwait(&sleepset, NULL, &tick); if (rc != -1) { - fprintf(stderr, "Received %s, wrapping things up.\n", + HDfprintf(stderr, "Received %s, wrapping things up.\n", strsignal(rc)); break; - } else if (rc == -1 && errno == EAGAIN) { + } + else if (rc == -1 && errno == EAGAIN) { estack_state_t es; /* Avoid deadlock with peer: periodically enter the API so that @@ -316,8 +327,11 @@ await_signal(hid_t fid) (void)H5Aexists_by_name(fid, "nonexistent", "nonexistent", H5P_DEFAULT); restore_estack(es); - } else if (rc == -1) - err(EXIT_FAILURE, "%s: sigtimedwait", __func__); + } + else if (rc == -1) { + HDfprintf(stderr, "%s: sigtimedwait", __func__); + HDexit(EXIT_FAILURE); + } } #endif /* H5_HAVE_SIGTIMEDWAIT */ } |