From 9159b93da623e5fdd95236322d79d003cce14c61 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 27 Apr 2020 10:07:36 -0500 Subject: Fix code that made GCC complain about a NULL or `unsigned char *` arguments for "%s". XXX The duplication between test/ros3.c test/s3comms.c is really annoying. --- test/ros3.c | 39 ++++++++++++++++++++++++--------------- test/s3comms.c | 36 +++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/test/ros3.c b/test/ros3.c index 73b6ac2..6618194 100644 --- a/test/ros3.c +++ b/test/ros3.c @@ -197,14 +197,19 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ +static inline void +jserr_long(long expected, long actual, const char *reason) +{ + if (reason != NULL) { + HDprintf("%s\n", reason); + } else { + HDprintf(" ! Expected %ld\n ! Actual %ld\n", expected, actual); + } +} + #define JSERR_LONG(expected, actual, reason) { \ JSFAILED_AT() \ - if (reason!= NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ - (long)(expected), (long)(actual)); \ - } \ + jserr_long((long)(expected), (long)(actual), (reason)); \ } @@ -236,18 +241,21 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ +static inline void +jserr_str(const char *expected, const char *actual, const char *reason) +{ + if (reason != NULL) { + HDprintf("%s\n", reason); + } else { + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", expected, actual); + } +} + #define JSERR_STR(expected, actual, reason) { \ JSFAILED_AT() \ - if ((reason) != NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ - (expected), (actual)); \ - } \ + jserr_str((expected), (actual), (reason)); \ } - - #ifdef JSVERIFY_EXP_ACT @@ -1594,7 +1602,8 @@ test_cmp(void) fapl_id = H5Pcreate(H5P_FILE_ACCESS); FAIL_IF( 0 > fapl_id ) - JSVERIFY( SUCCEED, H5Pset_fapl_ros3(fapl_id, &restricted_access_fa), NULL ) + JSVERIFY( SUCCEED, H5Pset_fapl_ros3(fapl_id, &restricted_access_fa), + NULL ) fd_raven = H5FDopen( url_text_public, diff --git a/test/s3comms.c b/test/s3comms.c index 9453b75..77dfc7d 100644 --- a/test/s3comms.c +++ b/test/s3comms.c @@ -185,14 +185,19 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ +static inline void +jserr_long(long expected, long actual, const char *reason) +{ + if (reason != NULL) { + HDprintf("%s\n", reason); + } else { + HDprintf(" ! Expected %ld\n ! Actual %ld\n", expected, actual); + } +} + #define JSERR_LONG(expected, actual, reason) { \ JSFAILED_AT() \ - if (reason!= NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ - (long)(expected), (long)(actual)); \ - } \ + jserr_long((long)(expected), (long)(actual), reason);\ } @@ -224,14 +229,19 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ +static inline void +jserr_str(const char *expected, const char *actual, const char *reason) +{ + if (reason != NULL) { + HDprintf("%s\n", reason); + } else { + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", expected, actual); + } +} + #define JSERR_STR(expected, actual, reason) { \ JSFAILED_AT() \ - if ((reason) != NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ - (expected), (actual)); \ - } \ + jserr_str((expected), (actual), (reason)); \ } #ifdef JSVERIFY_EXP_ACT @@ -2260,7 +2270,7 @@ test_signing_key(void) strncmp((const char *)cases[i].exp, (const char *)key, SHA256_DIGEST_LENGTH), - cases[i].exp ) + (const char *)cases[i].exp ) free(key); key = NULL; -- cgit v0.12