freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 81bdba1: * graph/*: Fix clang compilation warni


From: Werner Lemberg
Subject: [freetype2-demos] master 81bdba1: * graph/*: Fix clang compilation warnings.
Date: Sat, 20 Nov 2021 03:29:00 -0500 (EST)

branch: master
commit 81bdba1fbc6647f27d09c1c7c4e301db70969db1
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>

    * graph/*: Fix clang compilation warnings.
    
    Add casts for signed vs. unsigned issues.
---
 graph/batch/grbatch.c |  1 +
 graph/grfill.c        |  4 ++--
 graph/grobjs.c        | 20 ++++++++++----------
 graph/x11/grx11.c     | 11 +++++++----
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/graph/batch/grbatch.c b/graph/batch/grbatch.c
index c28d019..053b394 100644
--- a/graph/batch/grbatch.c
+++ b/graph/batch/grbatch.c
@@ -21,6 +21,7 @@
 /* FT graphics subsystem */
 #include "grobjs.h"
 #include "grdevice.h"
+#include "grbatch.h"
 
 
   static int
diff --git a/graph/grfill.c b/graph/grfill.c
index 91fa070..43d48dc 100644
--- a/graph/grfill.c
+++ b/graph/grfill.c
@@ -60,7 +60,7 @@ gr_fill_hline_4( unsigned char*  line,
                  int             incr,
                  grColor         color )
 {
-  int  col = color.value | (color.value << 4);
+  int  col = (int)( color.value | ( color.value << 4 ) );
   int  height;
 
   line += (x >> 1);
@@ -95,7 +95,7 @@ gr_fill_hline_8( unsigned char*   line,
   line += x;
 
   if ( incr == 1 )
-    memset( line, color.value, (size_t)width );
+    memset( line, (int)color.value, (size_t)width );
   else
   {
     /* there might be some pitch */
diff --git a/graph/grobjs.c b/graph/grobjs.c
index 717e074..04a5e70 100644
--- a/graph/grobjs.c
+++ b/graph/grobjs.c
@@ -30,15 +30,15 @@
         break;
 
       case gr_pixel_mode_rgb555:
-        color.value = ((red   & 0xF8) << 7) |
-                      ((green & 0xF8) << 2) |
-                      ((blue  & 0xF8) >> 3);
+        color.value = (uint32_t)( ( red   & 0xF8 ) << 7 ) |
+                      (uint32_t)( ( green & 0xF8 ) << 2 ) |
+                      (uint32_t)( ( blue  & 0xF8 ) >> 3 );
         break;
 
       case gr_pixel_mode_rgb565:
-        color.value = ((red   & 0xF8) << 8) |
-                      ((green & 0xFC) << 3) |
-                      ((blue  & 0xF8) >> 3);
+        color.value = (uint32_t)( ( red   & 0xF8 ) << 8 ) |
+                      (uint32_t)( ( green & 0xFC ) << 3 ) |
+                      (uint32_t)( ( blue  & 0xF8 ) >> 3 );
         break;
 
       case gr_pixel_mode_rgb24:
@@ -48,10 +48,10 @@
         break;
 
       case gr_pixel_mode_rgb32:
-        color.value = ((alpha & 0xFF) << 24) |
-                      ((red   & 0xFF) << 16) |
-                      ((green & 0xFF) <<  8) |
-                      ((blue  & 0xFF)      );
+        color.value = (uint32_t)( ( alpha & 0xFF ) << 24 ) |
+                      (uint32_t)( ( red   & 0xFF ) << 16 ) |
+                      (uint32_t)( ( green & 0xFF ) <<  8 ) |
+                      (uint32_t)( ( blue  & 0xFF )       );
         break;
 
       default:
diff --git a/graph/x11/grx11.c b/graph/x11/grx11.c
index ba18cbd..34d5c43 100644
--- a/graph/x11/grx11.c
+++ b/graph/x11/grx11.c
@@ -1012,7 +1012,10 @@
       surface->convert( &blit );
 
     /* without background defined, this only generates Expose event */
-    XClearArea( surface->display, surface->win, x, y, w, h, True );
+    XClearArea( surface->display, surface->win,
+                x, y,
+                (unsigned)w, (unsigned)h,
+                True );
   }
 
 
@@ -1043,12 +1046,12 @@
 
     sz = icon->rows * icon->width;
 
-    buffer = (unsigned long*)malloc( ( 2 + sz ) * sizeof( long) );
+    buffer = (unsigned long*)malloc( (size_t)( 2 + sz ) * sizeof ( long ) );
     if ( !buffer )
       return 0;
 
-    buffer[0] = icon->width;
-    buffer[1] = icon->rows;
+    buffer[0] = (unsigned long)icon->width;
+    buffer[1] = (unsigned long)icon->rows;
 
     /* must convert to long array */
     dst = buffer + 2;



reply via email to

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