More minor signedness warning fixes. * src/base/ftbbox.c, src/base/ftbitmap.c, src/base/fttrigon.c, src/base/ftutil.c: Apply.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
diff --git a/ChangeLog b/ChangeLog
index 7c6a52c..3a5529f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2015-02-16 Werner Lemberg <wl@gnu.org>
+ More minor signedness warning fixes.
+
+ * src/base/ftbbox.c, src/base/ftbitmap.c, src/base/fttrigon.c,
+ src/base/ftutil.c: Apply.
+
+2015-02-16 Werner Lemberg <wl@gnu.org>
+
Next round of minor compiler warning fixes.
* include/internal/ftrfork.h (FT_RFork_Ref): Change `offset' member
diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c
index ee1763b..10df98d 100644
--- a/src/base/ftbbox.c
+++ b/src/base/ftbbox.c
@@ -255,6 +255,7 @@
FT_Pos peak = 0;
FT_Int shift;
+
/* This function finds a peak of a cubic segment if it is above 0 */
/* using iterative bisection of the segment, or returns 0. */
/* The fixed-point arithmetic of bisection is inherently stable */
@@ -264,8 +265,10 @@
/* It is called with either q2 or q3 positive, which is necessary */
/* for the peak to exist and avoids undefined FT_MSB. */
- shift = 27 -
- FT_MSB( FT_ABS( q1 ) | FT_ABS( q2 ) | FT_ABS( q3 ) | FT_ABS( q4 ) );
+ shift = 27 - FT_MSB( (FT_UInt32)( FT_ABS( q1 ) |
+ FT_ABS( q2 ) |
+ FT_ABS( q3 ) |
+ FT_ABS( q4 ) ) );
if ( shift > 0 )
{
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index 98d49a3..094a7a1 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -117,7 +117,7 @@
FT_Byte* t = target->buffer;
- t += pitch * ( target->rows - 1 );
+ t += (FT_ULong)pitch * ( target->rows - 1 );
for ( i = target->rows; i > 0; i-- )
{
@@ -160,21 +160,21 @@
{
case FT_PIXEL_MODE_MONO:
bpp = 1;
- new_pitch = ( width + xpixels + 7 ) >> 3;
+ new_pitch = (int)( ( width + xpixels + 7 ) >> 3 );
break;
case FT_PIXEL_MODE_GRAY2:
bpp = 2;
- new_pitch = ( width + xpixels + 3 ) >> 2;
+ new_pitch = (int)( ( width + xpixels + 3 ) >> 2 );
break;
case FT_PIXEL_MODE_GRAY4:
bpp = 4;
- new_pitch = ( width + xpixels + 1 ) >> 1;
+ new_pitch = (int)( ( width + xpixels + 1 ) >> 1 );
break;
case FT_PIXEL_MODE_GRAY:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
bpp = 8;
- new_pitch = ( width + xpixels );
+ new_pitch = (int)( width + xpixels );
break;
default:
return FT_THROW( Invalid_Glyph_Format );
@@ -184,7 +184,7 @@
if ( ypixels == 0 && new_pitch <= pitch )
{
/* zero the padding */
- FT_UInt bit_width = pitch * 8;
+ FT_UInt bit_width = (FT_UInt)pitch * 8;
FT_UInt bit_last = ( width + xpixels ) * bpp;
@@ -227,8 +227,9 @@
for ( i = 0; i < bitmap->rows; i++ )
- FT_MEM_COPY( buffer + new_pitch * ( ypixels + i ),
- bitmap->buffer + pitch * i, len );
+ FT_MEM_COPY( buffer + (FT_UInt)new_pitch * ( ypixels + i ),
+ bitmap->buffer + (FT_UInt)pitch * i,
+ len );
}
else
{
@@ -236,8 +237,9 @@
for ( i = 0; i < bitmap->rows; i++ )
- FT_MEM_COPY( buffer + new_pitch * i,
- bitmap->buffer + pitch * i, len );
+ FT_MEM_COPY( buffer + (FT_UInt)new_pitch * i,
+ bitmap->buffer + (FT_UInt)pitch * i,
+ len );
}
FT_FREE( bitmap->buffer );
@@ -323,7 +325,8 @@
return FT_Err_Ok;
}
- error = ft_bitmap_assure_buffer( library->memory, bitmap, xstr, ystr );
+ error = ft_bitmap_assure_buffer( library->memory, bitmap,
+ (FT_UInt)xstr, (FT_UInt)ystr );
if ( error )
return error;
@@ -334,7 +337,7 @@
else
{
pitch = -pitch;
- p = bitmap->buffer + pitch * ( bitmap->rows - 1 );
+ p = bitmap->buffer + (FT_UInt)pitch * ( bitmap->rows - 1 );
}
/* for each row */
@@ -407,8 +410,8 @@
p += bitmap->pitch;
}
- bitmap->width += xstr;
- bitmap->rows += ystr;
+ bitmap->width += (FT_UInt)xstr;
+ bitmap->rows += (FT_UInt)ystr;
return FT_Err_Ok;
}
@@ -501,7 +504,7 @@
if ( old_target_pitch < 0 )
old_target_pitch = -old_target_pitch;
- old_size = target->rows * old_target_pitch;
+ old_size = target->rows * (FT_UInt)old_target_pitch;
target->pixel_mode = FT_PIXEL_MODE_GRAY;
target->rows = source->rows;
@@ -510,20 +513,20 @@
pad = 0;
if ( alignment > 0 )
{
- pad = source->width % alignment;
+ pad = (FT_Int)source->width % alignment;
if ( pad != 0 )
pad = alignment - pad;
}
- target_pitch = source->width + pad;
+ target_pitch = (FT_Int)source->width + pad;
- if ( target_pitch > 0 &&
- (FT_ULong)target->rows > FT_ULONG_MAX / target_pitch )
+ if ( target_pitch > 0 &&
+ (FT_ULong)target->rows > FT_ULONG_MAX / (FT_ULong)target_pitch )
return FT_THROW( Invalid_Argument );
- if ( target->rows * target_pitch > old_size &&
+ if ( target->rows * (FT_ULong)target_pitch > old_size &&
FT_QREALLOC( target->buffer,
- old_size, target->rows * target_pitch ) )
+ old_size, target->rows * (FT_UInt)target_pitch ) )
return error;
target->pitch = target->pitch < 0 ? -target_pitch : target_pitch;
@@ -539,9 +542,9 @@
/* take care of bitmap flow */
if ( source->pitch < 0 )
- s -= source->pitch * ( source->rows - 1 );
+ s -= source->pitch * (FT_Int)( source->rows - 1 );
if ( target->pitch < 0 )
- t -= target->pitch * ( target->rows - 1 );
+ t -= target->pitch * (FT_Int)( target->rows - 1 );
switch ( source->pixel_mode )
{
@@ -604,7 +607,7 @@
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
{
- FT_Int width = source->width;
+ FT_UInt width = source->width;
FT_UInt i;
diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c
index bdbc77b..a55920e 100644
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -92,8 +92,8 @@
s = -1;
}
- lo1 = val & 0x0000FFFFU;
- hi1 = val >> 16;
+ lo1 = (FT_UInt32)val & 0x0000FFFFU;
+ hi1 = (FT_UInt32)val >> 16;
lo2 = FT_TRIG_SCALE & 0x0000FFFFU;
hi2 = FT_TRIG_SCALE >> 16;
@@ -120,7 +120,7 @@
lo += 0x40000000UL;
hi += ( lo < 0x40000000UL );
- val = (FT_Fixed)hi;
+ val = (FT_Fixed)hi;
return s < 0 ? -val : val;
}
@@ -139,7 +139,7 @@
x = vec->x;
y = vec->y;
- shift = FT_MSB( FT_ABS( x ) | FT_ABS( y ) );
+ shift = FT_MSB( (FT_UInt32)( FT_ABS( x ) | FT_ABS( y ) ) );
if ( shift <= FT_TRIG_SAFE_MSB )
{
@@ -450,7 +450,7 @@
v.x = ft_trig_downscale( v.x );
if ( shift > 0 )
- return ( v.x + ( 1 << ( shift - 1 ) ) ) >> shift;
+ return ( v.x + ( 1L << ( shift - 1 ) ) ) >> shift;
return (FT_Fixed)( (FT_UInt32)v.x << -shift );
}
diff --git a/src/base/ftutil.c b/src/base/ftutil.c
index 221ce27..8c15afc 100644
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -180,7 +180,7 @@
FT_Error *p_error )
{
FT_Error error;
- FT_Pointer p = ft_mem_qalloc( memory, size, &error );
+ FT_Pointer p = ft_mem_qalloc( memory, (FT_Long)size, &error );
if ( !error && address )