From 7b193be887d3d84adddc5c1738799e53d1fc2754 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Wed, 29 Jun 2005 11:01:09 -0500 Subject: [svn-r10998] Purpose: Bug fix. Description: For the definition of the macro H5T_CONV_Xx_CORE, added a condition branch (else if (*((ST*)S) == (DT)(D_MAX))) which seems redundant. It handles a special situation when the source is "float" and assigned the value of "INT_MAX". A compiler may do roundup making this value "INT_MAX+1". However, when do comparison "if (*((ST*)S) > (DT)(D_MAX))", the compiler may consider them equal. Platforms tested: fuss - simple change. --- src/H5Tconv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 0386b8c..4690857 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -183,6 +183,12 @@ H5FL_BLK_DEFINE_STATIC(array_seq); *((DT*)D) = (DT)(*((ST*)S)); \ } +/* Added a condition branch(else if (*((ST*)S) == (DT)(D_MAX))) which seems redundant. + * It handles a special situation when the source is "float" and assigned the value + * of "INT_MAX". A compiler may do roundup making this value "INT_MAX+1". However, + * when do comparison "if (*((ST*)S) > (DT)(D_MAX))", the compiler may consider them + * equal. SLU - 2005/06/29 + */ #define H5T_CONV_Xx_CORE(S,D,STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ if(cb_struct.func) { \ @@ -199,6 +205,8 @@ H5FL_BLK_DEFINE_STATIC(array_seq); } \ else \ *((DT*)D) = (D_MAX); \ + } else if (*((ST*)S) == (DT)(D_MAX)) { \ + *((DT*)D) = (D_MAX); \ } else if (*((ST*)S) < (D_MIN)) { \ if(cb_struct.func) { \ H5T_conv_ret_t except_ret; /*callback return*/ \ @@ -214,7 +222,7 @@ H5FL_BLK_DEFINE_STATIC(array_seq); } \ else \ *((DT*)D) = (D_MIN); \ - } else \ + } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } -- cgit v0.12