[gucharmap] Fix a sign-compare warning



commit 2a7f9d61a413b83aaf84b33bdacc8847120eb9a3
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Jan 27 09:31:56 2012 -0500

    Fix a sign-compare warning
    
    We had
    
      if (signed < unsigned - unsigned)
    
    which had been 'fixed' to
    
      if (signed < (int)unsigned - unsigned)
    
    which didn't work because the subtraction between the two unsigned
    values caused the signed value to be promoted back to unsigned again.
    Change that to
    
      if (signed < (int) (unsigned - unsigned))
    
    which means that the signed math will be done on the unsigned ints, but
    the result will properly be interpreted as being signed before doing the
    compare.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668843

 gucharmap/gucharmap-block-codepoint-list.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/gucharmap/gucharmap-block-codepoint-list.c b/gucharmap/gucharmap-block-codepoint-list.c
index 913e015..7db5878 100644
--- a/gucharmap/gucharmap-block-codepoint-list.c
+++ b/gucharmap/gucharmap-block-codepoint-list.c
@@ -44,7 +44,7 @@ get_char (GucharmapCodepointList *list,
   GucharmapBlockCodepointList *block_list = GUCHARMAP_BLOCK_CODEPOINT_LIST (list);
   GucharmapBlockCodepointListPrivate *priv = block_list->priv;
 
-  if (index > (gint)priv->end - priv->start)
+  if (index > (gint) (priv->end - priv->start))
     return (gunichar)(-1);
   else
     return (gunichar) priv->start + index;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]