From 49d1022bdc9151273cf46c7e76b04c57009c1c0c Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Sun, 1 Aug 2021 22:07:01 -0500 Subject: [PATCH] Unsigned comparison to 0 warning avoidance (#869) * 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. * Better solution for avoiding warning that unsigned comparison < 0. --- src/H5.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/H5.c b/src/H5.c index 17afafeb6af..47d76979193 100644 --- a/src/H5.c +++ b/src/H5.c @@ -824,7 +824,11 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) disable_version_check = (unsigned int)HDstrtol(s, NULL, 0); } - if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE != relnum) { + /* H5_VERS_MAJOR and H5_VERS_MINOR must match */ + /* 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,