Fix sign-compare warnings
authorBehdad Esfahbod <behdad@behdad.org>
Sun, 30 Dec 2012 03:47:49 +0000 (22:47 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Sun, 30 Dec 2012 03:47:49 +0000 (22:47 -0500)
src/fccache.c
src/fcfreetype.c
src/fcint.h
src/fclang.c
src/fcname.c
src/fcxml.c
src/ftglue.c

index 3828b61..aace6b3 100644 (file)
@@ -527,7 +527,7 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat)
     FcCache    *cache;
     FcBool     allocated = FcFalse;
 
-    if (fd_stat->st_size < sizeof (FcCache))
+    if (fd_stat->st_size < (int) sizeof (FcCache))
        return NULL;
     cache = FcCacheFindByStat (fd_stat);
     if (cache)
@@ -582,7 +582,7 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat)
     }
     if (cache->magic != FC_CACHE_MAGIC_MMAP ||
        cache->version < FC_CACHE_CONTENT_VERSION ||
-       cache->size != fd_stat->st_size ||
+       cache->size != (intptr_t) fd_stat->st_size ||
        !FcCacheTimeValid (cache, dir_stat) ||
        !FcCacheInsert (cache, fd_stat))
     {
@@ -842,7 +842,7 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
     FcChar8        *test_dir;
     FcCacheSkip     *skip;
     struct stat     cache_stat;
-    int                    magic;
+    unsigned int    magic;
     int                    written;
 
     /*
index f4dfb80..9ac2fa9 100644 (file)
@@ -1117,8 +1117,8 @@ FcFreeTypeQueryFace (const FT_Face  face,
     int                    nstyle_lang = 0;
     int                    nfullname = 0;
     int                    nfullname_lang = 0;
-    int                    p, platform;
-    int                    n, nameid;
+    unsigned int    p, n;
+    int                    platform, nameid;
 
     FcChar8        *style = 0;
     int                    st;
@@ -1199,7 +1199,7 @@ FcFreeTypeQueryFace (const FT_Face  face,
                }
                else
                {
-                   int     sp;
+                   unsigned int        sp;
 
                    for (sp = 0; sp < NUM_PLATFORM_ORDER; sp++)
                        if (sname.platform_id == platform_order[sp])
index 2cb7805..8b5a104 100644 (file)
@@ -358,7 +358,7 @@ typedef struct _FcStrBuf {
 } FcStrBuf;
 
 struct _FcCache {
-    int                magic;              /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */
+    unsigned int magic;              /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */
     int                version;            /* FC_CACHE_CONTENT_VERSION */
     intptr_t   size;               /* size of file */
     intptr_t   dir;                /* offset to dir name */
@@ -451,7 +451,7 @@ typedef struct _FcCaseFold {
 
 #define FC_CACHE_MAGIC_MMAP        0xFC02FC04
 #define FC_CACHE_MAGIC_ALLOC       0xFC02FC05
-#define FC_CACHE_CONTENT_VERSION    3 /* also check FC_CACHE_VERSION */
+#define FC_CACHE_CONTENT_VERSION    3
 
 struct _FcAtomic {
     FcChar8    *file;          /* original file name */
index 65d22a9..57183fd 100644 (file)
@@ -51,7 +51,7 @@ static void
 FcLangSetBitSet (FcLangSet    *ls,
                 unsigned int  id)
 {
-  int bucket;
+  unsigned int bucket;
 
   id = fcLangCharSetIndices[id];
   bucket = id >> 5;
@@ -65,7 +65,7 @@ static FcBool
 FcLangSetBitGet (const FcLangSet *ls,
                 unsigned int     id)
 {
-  int bucket;
+  unsigned int bucket;
 
   id = fcLangCharSetIndices[id];
   bucket = id >> 5;
@@ -79,7 +79,7 @@ static void
 FcLangSetBitReset (FcLangSet    *ls,
                   unsigned int  id)
 {
-  int bucket;
+  unsigned int bucket;
 
   id = fcLangCharSetIndices[id];
   bucket = id >> 5;
index 0ad508b..5540b6f 100644 (file)
@@ -307,7 +307,7 @@ FcObjectValidType (FcObject object, FcType type)
                return FcTrue;
            break;
        default:
-           if (t->type == -1 || type == t->type)
+           if (t->type == (unsigned int) -1 || type == t->type)
                return FcTrue;
            break;
        }
@@ -343,7 +343,7 @@ FcObjectGetSet (void)
 FcBool
 FcObjectInit (void)
 {
-    int        i;
+    unsigned int       i;
 
     if (FcObjectsInited)
        return FcTrue;
@@ -371,7 +371,7 @@ FcObjectFini (void)
        FcObjectBuckets[i] = 0;
     }
     for (i = 0; i < FcObjectsNumber; i++)
-       if (FcObjects[i].type == -1)
+       if (FcObjects[i].type == (unsigned int) -1)
            free ((void*) FcObjects[i].object);
     if (FcObjects != _FcBaseObjectTypes)
        free (FcObjects);
index 3e2a42b..3ae6b7a 100644 (file)
@@ -508,9 +508,9 @@ typedef struct _FcConfigParse {
     const FcChar8   *name;
     FcConfig       *config;
     XML_Parser     parser;
-    int             pstack_static_used;
+    unsigned int    pstack_static_used;
     FcPStack        pstack_static[8];
-    int             vstack_static_used;
+    unsigned int    vstack_static_used;
     FcVStack        vstack_static[64];
 } FcConfigParse;
 
index 7c643d0..ac5f121 100644 (file)
@@ -87,7 +87,7 @@ ftglue_stream_seek( FT_Stream   stream,
     if ( stream->read( stream, pos, 0, 0 ) )
       error = FT_Err_Invalid_Stream_Operation;
   }
-  else if ( pos > stream->size )
+  else if ( pos < 0 || (FT_ULong) pos > stream->size )
     error = FT_Err_Invalid_Stream_Operation;
 
   if ( !error )