From 4248e9562c05985493feeeaf69a5b0809b405505 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Thu, 29 Jul 2021 13:07:22 -0500 Subject: [PATCH 1/2] Added int variable for comparison with H5_VERS_RELEASE in H5.c to avoid warning that unsigned comparison < 0 is always false, which is known, but for later versions the comparison can possibly be true. --- src/H5.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/H5.c b/src/H5.c index 12d226c2b19..2debc92d32a 100644 --- a/src/H5.c +++ b/src/H5.c @@ -912,6 +912,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */ static const char * version_mismatch_warning = VERSION_MISMATCH_WARNING; herr_t ret_value = SUCCEED; /* Return value */ + int releasenum = relnum; /* To avoid warning for unsigned < 0 + comparison in first release versions */ FUNC_ENTER_API_NOINIT_NOERR_NOFS H5TRACE3("e", "IuIuIu", majnum, minnum, relnum); @@ -931,7 +933,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) } /* H5_VERS_MAJOR and H5_VERS_MINOR must match */ - if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE > relnum) { + if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE > releasenum) { switch (disable_version_check) { case 0: HDfprintf(stderr, "%s%s", version_mismatch_warning, From 4827d23920d1e6cb6f6d09fc773a583c6d18aab3 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Fri, 30 Jul 2021 09:20:14 -0500 Subject: [PATCH 2/2] Better solution for avoiding warning that unsigned comparison < 0. --- src/H5.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/H5.c b/src/H5.c index 2debc92d32a..8bbc0033870 100644 --- a/src/H5.c +++ b/src/H5.c @@ -912,8 +912,6 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */ static const char * version_mismatch_warning = VERSION_MISMATCH_WARNING; herr_t ret_value = SUCCEED; /* Return value */ - int releasenum = relnum; /* To avoid warning for unsigned < 0 - comparison in first release versions */ FUNC_ENTER_API_NOINIT_NOERR_NOFS H5TRACE3("e", "IuIuIu", majnum, minnum, relnum); @@ -933,7 +931,9 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) } /* H5_VERS_MAJOR and H5_VERS_MINOR must match */ - if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE > releasenum) { + /* Cast relnum to int to avoid warning for unsigned < 0 comparison + * in first release versions */ + if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE > (int)relnum) { switch (disable_version_check) { case 0: HDfprintf(stderr, "%s%s", version_mismatch_warning,