From 0a9c1e69d8f2a064fede7a2e9f41ec19be06fd36 Mon Sep 17 00:00:00 2001 From: "H. Joe Lee" Date: Fri, 30 Aug 2024 11:06:52 -0500 Subject: [PATCH 1/3] Fix grammar and simplify comment in H5Fint.c (#4790) --- src/H5Fint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Fint.c b/src/H5Fint.c index 190d1b25486..f653e0b71f0 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1985,7 +1985,7 @@ H5F_open(bool try, H5F_t **_file, const char *name, unsigned flags, hid_t fcpl_i if ((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "can't have both SWMR and cache image"); - /* Retain the name the file was opened with */ + /* Retain the original filename. */ file->open_name = H5MM_xstrdup(name); /* Short cuts */ From e66ec4f5eebdba86679b3994271e71187592ea02 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 30 Aug 2024 14:11:01 -0500 Subject: [PATCH 2/3] Resolve race around single counter by using two counters (#4792) --- test/ttsafe_semaphore.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/ttsafe_semaphore.c b/test/ttsafe_semaphore.c index 37c8ed29941..b8a3dece723 100644 --- a/test/ttsafe_semaphore.c +++ b/test/ttsafe_semaphore.c @@ -20,14 +20,15 @@ #if defined(H5_HAVE_THREADS) -#define NUM_PINGPONG (500 * 1000) +#define NUM_PINGPONG (250 * 1000) #define NUM_CLIENTSERVER (50 * 1000) #define NUM_THREADS 16 typedef struct { H5TS_semaphore_t ping_sem, pong_sem; - H5TS_atomic_uint_t counter; + H5TS_atomic_uint_t ping_counter; + H5TS_atomic_uint_t pong_counter; } pingpong_t; typedef struct { @@ -47,11 +48,11 @@ ping(void *_test_info) result = H5TS_semaphore_wait(&test_info->ping_sem); CHECK_I(result, "H5TS_semaphore_wait"); - H5TS_atomic_fetch_add_uint(&test_info->counter, (unsigned)1); + H5TS_atomic_fetch_add_uint(&test_info->ping_counter, (unsigned)1); result = H5TS_semaphore_signal(&test_info->pong_sem); CHECK_I(result, "H5TS_semaphore_signal"); - } while (H5TS_atomic_load_uint(&test_info->counter) < NUM_PINGPONG); + } while (H5TS_atomic_load_uint(&test_info->ping_counter) < NUM_PINGPONG); return ret_value; } @@ -67,11 +68,11 @@ pong(void *_test_info) result = H5TS_semaphore_wait(&test_info->pong_sem); CHECK_I(result, "H5TS_semaphore_wait"); - H5TS_atomic_fetch_add_uint(&test_info->counter, (unsigned)1); + H5TS_atomic_fetch_add_uint(&test_info->pong_counter, (unsigned)1); result = H5TS_semaphore_signal(&test_info->ping_sem); CHECK_I(result, "H5TS_semaphore_signal"); - } while (H5TS_atomic_load_uint(&test_info->counter) < NUM_PINGPONG); + } while (H5TS_atomic_load_uint(&test_info->pong_counter) < NUM_PINGPONG); return ret_value; } @@ -93,7 +94,8 @@ tts_semaphore_pingpong(void) CHECK_I(result, "H5TS_semaphore_init"); result = H5TS_semaphore_init(&test_info.pong_sem, 0); CHECK_I(result, "H5TS_semaphore_init"); - H5TS_atomic_init_uint(&test_info.counter, (unsigned)0); + H5TS_atomic_init_uint(&test_info.ping_counter, (unsigned)0); + H5TS_atomic_init_uint(&test_info.pong_counter, (unsigned)0); /* Start ping & pong threads */ result = H5TS_thread_create(&ping_thread, ping, &test_info); @@ -111,7 +113,8 @@ tts_semaphore_pingpong(void) result = H5TS_thread_join(pong_thread, NULL); CHECK_I(result, "H5TS_thread_join"); - VERIFY(H5TS_atomic_load_uint(&test_info.counter), (NUM_PINGPONG + 1), "ping pong"); + VERIFY(H5TS_atomic_load_uint(&test_info.ping_counter), NUM_PINGPONG, "ping counter"); + VERIFY(H5TS_atomic_load_uint(&test_info.pong_counter), NUM_PINGPONG, "pong counter"); /* Destroy semaphores, etc. */ result = H5TS_semaphore_destroy(&test_info.ping_sem); @@ -119,7 +122,8 @@ tts_semaphore_pingpong(void) result = H5TS_semaphore_destroy(&test_info.pong_sem); CHECK_I(result, "H5TS_semaphore_destroy"); - H5TS_atomic_destroy_uint(&test_info.counter); + H5TS_atomic_destroy_uint(&test_info.ping_counter); + H5TS_atomic_destroy_uint(&test_info.pong_counter); } /* end tts_semaphore_pingpong() */ static H5TS_THREAD_RETURN_TYPE From 008b7ba708e4e9faa55e15e11d95c42b124e74e2 Mon Sep 17 00:00:00 2001 From: "H. Joe Lee" Date: Fri, 30 Aug 2024 14:13:06 -0500 Subject: [PATCH 3/3] Fix char-subscripts warnings in H5private.h (#4793) --- src/H5private.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/H5private.h b/src/H5private.h index ab005067668..9950d0ccadc 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1129,34 +1129,34 @@ H5_DLL herr_t H5_trace_args(struct H5RS_str_t *rs, const char *type, va_list ap) * Handles H5XY_. */ #define H5_IS_API(S) \ - ('_' != ((const char *)S)[2] /* underscore at position 2 */ \ - && '_' != ((const char *)S)[3] /* underscore at position 3 */ \ - && !( /* NOT */ \ - ((const char *)S)[4] /* pos 4 exists */ \ - && (isupper(S[3]) || isdigit(S[3])) /* pos 3 dig | uc */ \ - && '_' == ((const char *)S)[4] /* pos 4 underscore */ \ + ('_' != ((const char *)S)[2] /* underscore at position 2 */ \ + && '_' != ((const char *)S)[3] /* underscore at position 3 */ \ + && !( /* NOT */ \ + ((const char *)S)[4] /* pos 4 exists */ \ + && (isupper((int)S[3]) || isdigit((int)S[3])) /* pos 3 dig | uc */ \ + && '_' == ((const char *)S)[4] /* pos 4 underscore */ \ )) /* `S' is the name of a function which is being tested to check if it's */ /* a public API function */ #define H5_IS_PUB(S) \ - (((isdigit(S[1]) || isupper(S[1])) && islower(S[2])) || \ - ((isdigit(S[2]) || isupper(S[2])) && islower(S[3])) || \ - (!S[4] || ((isdigit(S[3]) || isupper(S[3])) && islower(S[4])))) + (((isdigit((int)S[1]) || isupper((int)S[1])) && islower((int)S[2])) || \ + ((isdigit((int)S[2]) || isupper((int)S[2])) && islower((int)S[3])) || \ + (!S[4] || ((isdigit((int)S[3]) || isupper((int)S[3])) && islower((int)S[4])))) /* `S' is the name of a function which is being tested to check if it's */ /* a private library function */ #define H5_IS_PRIV(S) \ - (((isdigit(S[1]) || isupper(S[1])) && '_' == S[2] && islower(S[3])) || \ - ((isdigit(S[2]) || isupper(S[2])) && '_' == S[3] && islower(S[4])) || \ - ((isdigit(S[3]) || isupper(S[3])) && '_' == S[4] && islower(S[5]))) + (((isdigit((int)S[1]) || isupper((int)S[1])) && '_' == S[2] && islower((int)S[3])) || \ + ((isdigit((int)S[2]) || isupper((int)S[2])) && '_' == S[3] && islower((int)S[4])) || \ + ((isdigit((int)S[3]) || isupper((int)S[3])) && '_' == S[4] && islower((int)S[5]))) /* `S' is the name of a function which is being tested to check if it's */ /* a package private function */ #define H5_IS_PKG(S) \ - (((isdigit(S[1]) || isupper(S[1])) && '_' == S[2] && '_' == S[3] && islower(S[4])) || \ - ((isdigit(S[2]) || isupper(S[2])) && '_' == S[3] && '_' == S[4] && islower(S[5])) || \ - ((isdigit(S[3]) || isupper(S[3])) && '_' == S[4] && '_' == S[5] && islower(S[6]))) + (((isdigit((int)S[1]) || isupper((int)S[1])) && '_' == S[2] && '_' == S[3] && islower((int)S[4])) || \ + ((isdigit((int)S[2]) || isupper((int)S[2])) && '_' == S[3] && '_' == S[4] && islower((int)S[5])) || \ + ((isdigit((int)S[3]) || isupper((int)S[3])) && '_' == S[4] && '_' == S[5] && islower((int)S[6]))) /* global library version information string */ extern char H5_lib_vers_info_g[];