[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Avoid warning when char is unsigned

From: Mattias Engdegård <mattiase_at_bredband.net>
Date: Sat, 13 Apr 2013 20:43:47 +0200

This trivial non-essential patch avoids a warning when building with -
Wall.

[[[
Avoid a "condition always true" warning on platforms where char
is unsigned by default, such as PowerPC and ARM.

* subversion/libsvn_subr/utf_validate.c
   (first_non_fsm_start_char, first_non_fsm_start_char_cstring):
    Add explicit cast to avoid warning when plain char is unsigned.
]]]

Index: utf_validate.c
===================================================================
--- utf_validate.c (revision 1467576)
+++ utf_validate.c (working copy)
@@ -271,7 +271,7 @@
       max_len -= len;
 
       for (; len > 0; ++data, --len)
- if (*data < 0 || *data >= 0x80)
+ if ((unsigned char)*data >= 0x80)
           return data;
     }
 
@@ -285,7 +285,7 @@
 
   /* The remaining odd bytes will be examined the naive way: */
   for (; max_len > 0; ++data, --max_len)
- if (*data < 0 || *data >= 0x80)
+ if ((unsigned char)*data >= 0x80)
       break;
 
   return data;
@@ -304,7 +304,7 @@
    * segfault.
    */
   for (; (apr_uintptr_t)data & (sizeof(apr_uintptr_t)-1); ++data)
- if (*data <= 0 || *data >= 0x80)
+ if (*data == 0 || (unsigned char)*data >= 0x80)
       return data;
 
   /* Scan the input one machine word at a time. */
@@ -331,7 +331,7 @@
 
   /* The remaining odd bytes will be examined the naive way: */
   for (; ; ++data)
- if (*data <= 0 || *data >= 0x80)
+ if (*data == 0 || (unsigned char)*data >= 0x80)
       break;
 
   return data;

Received on 2013-04-13 20:44:21 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.