summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-10-22 18:30:14 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2022-10-22 18:30:14 +0100
commit04976d7f23da03e4bebbe50fd3548c8b4d7c26fc (patch)
treec2f289d67ace26c0f9710eb71e9f693a6c4f4778
parent5926dfdd6fa9053ed40d9b0207b563cf3aec48d1 (diff)
downloadlibcss-04976d7f23da03e4bebbe50fd3548c8b4d7c26fc.tar.gz
libcss-04976d7f23da03e4bebbe50fd3548c8b4d7c26fc.tar.bz2
Floating point maths: Squash clang warning
Implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
-rw-r--r--include/libcss/fpmath.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/libcss/fpmath.h b/include/libcss/fpmath.h
index bed5ee6..d7cac4d 100644
--- a/include/libcss/fpmath.h
+++ b/include/libcss/fpmath.h
@@ -99,10 +99,12 @@ css_float_to_fixed(const float a) {
float xx = a * (float) (1 << CSS_RADIX_POINT);
if (xx < INT_MIN)
- xx = INT_MIN;
+ return INT_MIN;
- if (xx > INT_MAX)
- xx = INT_MAX;
+ /* Conversion from int to float changes value from
+ * 2147483647 to 2147483648, so we use >= instead of >. */
+ if (xx >= (float)INT_MAX)
+ return INT_MAX;
return (css_fixed) xx;
}