From: pi1024e <49824824+pi1024e@users.noreply.github.com> Date: Mon, 24 Feb 2020 18:50:57 +0000 (-0500) Subject: Fix compilation warning (#32740) X-Git-Tag: submit/tizen/20210909.063632~9533 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1905bde27967bff71c95ec5cbf2e099d80dce5f4;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix compilation warning (#32740) When compiling, Visual Studio gives two compiler warnings in the sysmath.c file about FPILOGB0/-2147483648 being converted into an unsigned integer. The standard library math.h states that FPILOGB0 be INT_MIN, so I replaced -2147483648 with the INT_MIN macro so the behavior is much more clear as well as stifling the compiler warnings. Changes tested manually and automatically. --- diff --git a/src/mono/mono/metadata/sysmath.c b/src/mono/mono/metadata/sysmath.c index 3cef4c1..5515657 100644 --- a/src/mono/mono/metadata/sysmath.c +++ b/src/mono/mono/metadata/sysmath.c @@ -204,14 +204,12 @@ ves_icall_System_Math_Ceiling (gdouble v) gint32 ves_icall_System_Math_ILogB (gdouble x) { - int ret; - if (FP_ILOGB0 != -2147483648 && x == 0.0) - ret = -2147483648; - else if (FP_ILOGBNAN != 2147483647 && isnan(x)) - ret = 2147483647; - else - ret = ilogb(x); - return ret; + if (FP_ILOGB0 != INT_MIN && x == 0.0) + return INT_MIN; + if (FP_ILOGBNAN != INT_MAX && isnan(x)) + return INT_MAX; + + return ilogb(x); } gdouble @@ -375,14 +373,12 @@ ves_icall_System_MathF_ModF (float x, float *d) gint32 ves_icall_System_MathF_ILogB (float x) { - int ret; - if (FP_ILOGB0 != -2147483648 && x == 0.0) - ret = -2147483648; - else if (FP_ILOGBNAN != 2147483647 && isnan(x)) - ret = 2147483647; - else - ret = ilogbf(x); - return ret; + if (FP_ILOGB0 != INT_MIN && x == 0.0) + return INT_MIN; + if (FP_ILOGBNAN != INT_MAX && isnan(x)) + return INT_MAX; + + return ilogbf(x); } float