[PATCH:libXi] Fix size comparison.

Thomas Klausner wiz at NetBSD.org
Thu Jun 27 05:55:27 PDT 2013


This addresses the following clang-3.4 warning:
XGetFCtl.c:129:32: warning: comparison of constant 268435455 with expression of type 'CARD16' (aka 'unsigned short') is always false
      [-Wtautological-constant-out-of-range-compare]
                if (strf->num_syms_supported >= (INT_MAX / sizeof(KeySym)))
                    ~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
---
 src/XGetFCtl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/XGetFCtl.c b/src/XGetFCtl.c
index bb50bf3..100ae9e 100644
--- a/src/XGetFCtl.c
+++ b/src/XGetFCtl.c
@@ -126,7 +126,7 @@ XGetFeedbackControl(
 	    {
 		xStringFeedbackState *strf = (xStringFeedbackState *) f;
 
-		if (strf->num_syms_supported >= (INT_MAX / sizeof(KeySym)))
+		if (strf->num_syms_supported >= (SHRT_MAX / sizeof(KeySym)))
 		    goto out;
 		size += sizeof(XStringFeedbackState) +
 		    (strf->num_syms_supported * sizeof(KeySym));
-- 
1.8.3.1



More information about the xorg-devel mailing list