freetype-devel
[Top][All Lists]
Advanced

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

Fix build warning with bionic libc on Android


From: Seigo Nonaka
Subject: Fix build warning with bionic libc on Android
Date: Tue, 23 Nov 2021 16:18:44 -0800

Hi FreeType developers,

I'm Seigo Nonaka working on Android. I found a build warning in the latest FreeType source code and likely this only happens with the bionic libc used in Android.

Here is the proposed patch for fixing warnings. Hope this can be merged to the trunk of FreeType. 

Thank you.
Seigo


Author: Seigo Nonaka <nona@google.com>
Date:   Tue Nov 23 16:08:11 2021 -0800

    Fix build warning on Android
   
    scaled_w and scaled_d in ftobj.c is FT_Long (a.k.a signed long) and
    FT_USHORT_MAX is unsigned short in bionic (libc used in Android).
    The bionic defines USHRT_MAX as 0xffffU which is unsigned, then 
    the compiler warns against the signed-unsigned comparison.
   
    To fix this warning, cast FT_USHORT_MAX to FT_Long before comparing.

diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 62475d4e9..883f1a897 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -3230,8 +3230,8 @@
 
       scaled_w = ( scaled_w + 32 ) >> 6;
       scaled_h = ( scaled_h + 32 ) >> 6;
-      if ( scaled_w > FT_USHORT_MAX ||
-           scaled_h > FT_USHORT_MAX )
+      if ( scaled_w > (FT_Long)FT_USHORT_MAX ||
+           scaled_h > (FT_Long)FT_USHORT_MAX )
       {
         FT_ERROR(( "FT_Request_Metrics: Resulting ppem size too large\n" ));
         error = FT_ERR( Invalid_Pixel_Size );

reply via email to

[Prev in Thread] Current Thread [Next in Thread]