[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 66991af 2/2: * src/*: Fix clang warnings.
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] master 66991af 2/2: * src/*: Fix clang warnings. |
Date: |
Mon, 15 Nov 2021 11:16:39 -0500 (EST) |
branch: master
commit 66991afefb86108b270220c42871ffa992c1f0f7
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>
* src/*: Fix clang warnings.
All of them are minor and belong to one of the following categories:
* signedness casts
* corrected `printf` signatures
* missing `static` keyword for local functions
---
src/ftcommon.c | 4 ++--
src/ftdump.c | 10 +++++-----
src/ftgrid.c | 2 +-
src/ftlint.c | 24 ++++++++++++++----------
src/ftmulti.c | 7 ++++---
src/ftpngout.c | 3 ++-
src/ftsdf.c | 48 ++++++++++++++++++++++++++++++++----------------
src/ftstring.c | 2 +-
src/ftview.c | 2 +-
src/strbuf.c | 4 ++--
10 files changed, 64 insertions(+), 42 deletions(-)
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 36eeefe..6e4f03e 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -466,7 +466,7 @@
for ( ; count--; spans++ )
for ( dst = dst_line + spans->x, w = spans->len; w--; dst++ )
- *dst = ( spans->coverage << 24 ) | color;
+ *dst = (FT_UInt32)( spans->coverage << 24 ) | color;
}
@@ -1172,7 +1172,7 @@
strbuf_reset( buf );
FTDemo_Get_Info( handle, buf );
grWriteCellString( display->bitmap,
- display->bitmap->width - 8 * strbuf_len( buf ),
+ display->bitmap->width - 8 * (int)strbuf_len( buf ),
line * HEADER_HEIGHT,
strbuf_value( buf ), display->fore_color );
diff --git a/src/ftdump.c b/src/ftdump.c
index 1e7a769..b89bb5f 100644
--- a/src/ftdump.c
+++ b/src/ftdump.c
@@ -149,8 +149,8 @@
if ( head )
{
char buf[11];
- time_t created = head->Created [1];
- time_t modified = head->Modified[1];
+ time_t created = (time_t)head->Created [1];
+ time_t modified = (time_t)head->Modified[1];
/* ignore most of upper bits until 2176 and adjust epoch */
@@ -536,8 +536,8 @@
else if ( !FT_Get_BDF_Charset_ID( face, &encoding, ®istry ) )
printf( ", charset %s-%s", registry, encoding );
else if ( !FT_Get_WinFNT_Header( face, &header ) )
- printf( header.charset < 10 ? ", charset %hu"
- : ", charset %hu <%hX>",
+ printf( header.charset < 10 ? ", charset %hhu"
+ : ", charset %hhu <%hhX>",
header.charset, header.charset );
printf ( "\n" );
@@ -566,7 +566,7 @@
}
else if ( coverage == 1 )
{
- FT_ULong next, last = ~1;
+ FT_ULong next, last = ~1U;
FT_UInt gindex;
const char* f1 = "";
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 8d180c2..ecd9c02 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -1053,7 +1053,7 @@
/* The floating scale is reversibly adjusted after decomposing it into */
/* fraction and exponent. Direct bit manipulation is less portable. */
- frc = 8 * frexpf( status.scale, &exp );
+ frc = (int)( 8 * frexpf( status.scale, &exp ) );
frc = ( frc & 3 ) | ( exp << 2 );
frc += step;
diff --git a/src/ftlint.c b/src/ftlint.c
index 137a898..e55b5cd 100644
--- a/src/ftlint.c
+++ b/src/ftlint.c
@@ -97,14 +97,16 @@
for ( d0 = d1 = 0, j = 0; j < bitmap->width; j++, b++ )
{
d1 -= *b;
- s2 += d1 >= d0 ? d1 - d0 : d0 - d1; /* second derivative sum */
- s1 += d1 >= 0 ? d1 : -d1; /* first derivative sum */
+ /* second derivative sum */
+ s2 += (unsigned long)( d1 >= d0 ? d1 - d0 : d0 - d1 );
+ /* first derivative sum */
+ s1 += (unsigned long)( d1 >= 0 ? d1 : -d1 );
d0 = d1;
d1 = *b;
}
- s2 += d1 > d0 ? d1 - d0 : d0 - d1;
- s2 += d1;
- s1 += d1;
+ s2 += (unsigned long)( d1 > d0 ? d1 - d0 : d0 - d1 );
+ s2 += (unsigned long)d1;
+ s1 += (unsigned long)d1;
}
printf( "%.4lf ", s1 ? (double)s2 / s1 : 2.0 );
@@ -116,14 +118,16 @@
for ( d0 = d1 = 0, i = 0; i < bitmap->rows; i++, b += bitmap->pitch )
{
d1 -= *b;
- s2 += d1 >= d0 ? d1 - d0 : d0 - d1; /* second derivative sum */
- s1 += d1 >= 0 ? d1 : -d1; /* first derivative sum */
+ /* second derivative sum */
+ s2 += (unsigned long)( d1 >= d0 ? d1 - d0 : d0 - d1 );
+ /* first derivative sum */
+ s1 += (unsigned long)( d1 >= 0 ? d1 : -d1 );
d0 = d1;
d1 = *b;
}
- s2 += d1 > d0 ? d1 - d0 : d0 - d1;
- s2 += d1;
- s1 += d1;
+ s2 += (unsigned long)( d1 > d0 ? d1 - d0 : d0 - d1 );
+ s2 += (unsigned long)d1;
+ s1 += (unsigned long)d1;
}
printf( "%.4lf ", s1 ? (double)s2 / s1 : 2.0 );
diff --git a/src/ftmulti.c b/src/ftmulti.c
index c68f8e5..8faf02c 100644
--- a/src/ftmulti.c
+++ b/src/ftmulti.c
@@ -261,7 +261,7 @@
}
}
- num_shown_axes = idx + 1;
+ num_shown_axes = (unsigned int)( idx + 1 );
}
else
{
@@ -270,7 +270,7 @@
/* show all axes */
for ( i = 0; i < used_num_axis; i++ )
- shown_axes[i] = i;
+ shown_axes[i] = (int)i;
num_shown_axes = used_num_axis;
}
@@ -282,7 +282,8 @@
Clear_Display( void )
{
memset( bit->buffer, 0, (size_t)bit->rows *
- ( bit->pitch < 0 ? -bit->pitch : bit->pitch ) );
+ (size_t)( bit->pitch < 0 ? -bit->pitch
+ : bit->pitch ) );
}
diff --git a/src/ftpngout.c b/src/ftpngout.c
index 8e01367..426d09f 100644
--- a/src/ftpngout.c
+++ b/src/ftpngout.c
@@ -84,7 +84,8 @@
png_init_io( png_ptr, fp );
/* Write header (8 bit colour depth) */
- png_set_IHDR( png_ptr, info_ptr, width, height,
+ png_set_IHDR( png_ptr, info_ptr,
+ (png_uint_32)width, (png_uint_32)height,
8, color_type, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE );
diff --git a/src/ftsdf.c b/src/ftsdf.c
index 45a7a6a..de0d74f 100644
--- a/src/ftsdf.c
+++ b/src/ftsdf.c
@@ -1,3 +1,17 @@
+/****************************************************************************/
+/* */
+/* The FreeType project -- a free and portable quality TrueType renderer. */
+/* */
+/* Copyright (C) 2021 by */
+/* D. Turner, R.Wilhelm, W. Lemberg, and Anuj Verma */
+/* */
+/* */
+/* FTSdf - a simple font viewer for FreeType's SDF output. */
+/* */
+/* Press ? when running this program to have a list of key-bindings. */
+/* */
+/****************************************************************************/
+
#include <freetype/ftmodapi.h>
@@ -31,7 +45,7 @@
FT_Face face;
FT_Int ptsize;
FT_Int glyph_index;
- FT_Int scale;
+ FT_UInt scale;
FT_Int spread;
FT_Int x_offset;
FT_Int y_offset;
@@ -89,8 +103,8 @@
&status.overlaps ) );
/* Set pixel size and load the glyph index. */
- FT_CALL( FT_Set_Pixel_Sizes( status.face, 0, status.ptsize ) );
- FT_CALL( FT_Load_Glyph( status.face, status.glyph_index,
+ FT_CALL( FT_Set_Pixel_Sizes( status.face, 0, (FT_UInt)status.ptsize ) );
+ FT_CALL( FT_Load_Glyph( status.face, (FT_UInt)status.glyph_index,
FT_LOAD_DEFAULT ) );
/* This is just to measure the generation time. */
@@ -209,7 +223,7 @@
sprintf( header_string,
- "Glyph Index: %d, Pt Size: %d, Spread: %d, Scale: %d",
+ "Glyph Index: %d, Pt Size: %d, Spread: %d, Scale: %u",
status.glyph_index,
status.ptsize,
status.spread,
@@ -258,7 +272,7 @@
grEvent event;
int ret = 0;
- int speed = 10 * status.scale;
+ int speed = 10 * (int)status.scale;
grListenSurface( display->surface, 0, &event );
@@ -393,7 +407,7 @@
/* Clamp value `x` between `lower_limit` and `upper_limit`. */
- float
+ static float
clamp( float x,
float lower_limit,
float upper_limit )
@@ -413,7 +427,7 @@
/* This implementation is taken from Wikipedia. */
/* */
/* https://en.wikipedia.org/wiki/Smoothstep */
- float
+ static float
smoothstep( float edge0,
float edge1,
float x )
@@ -456,10 +470,10 @@
center.y = display->bitmap->rows / 2;
/* compute draw region around `center` */
- draw_region.xMin = center.x - ( bitmap->width * status.scale) / 2;
- draw_region.xMax = center.x + ( bitmap->width * status.scale) / 2;
- draw_region.yMin = center.y - ( bitmap->rows * status.scale) / 2;
- draw_region.yMax = center.y + ( bitmap->rows * status.scale) / 2;
+ draw_region.xMin = center.x - ( bitmap->width * status.scale ) / 2;
+ draw_region.xMax = center.x + ( bitmap->width * status.scale ) / 2;
+ draw_region.yMin = center.y - ( bitmap->rows * status.scale ) / 2;
+ draw_region.yMax = center.y + ( bitmap->rows * status.scale ) / 2;
/* add position offset so that we can move the image */
draw_region.xMin += status.x_offset;
@@ -509,23 +523,25 @@
/* Finally loop over all pixels inside the draw region */
/* and copy pixels from the sample region to the draw region. */
- for ( FT_Int j = draw_region.yMax - 1, y = sample_region.yMin;
+ for ( FT_UInt j = (FT_UInt)( draw_region.yMax - 1 ),
+ y = (FT_UInt)sample_region.yMin;
j >= draw_region.yMin;
j--, y++ )
{
- for ( FT_Int i = draw_region.xMin, x = sample_region.xMin;
+ for ( FT_UInt i = (FT_UInt)draw_region.xMin,
+ x = (FT_UInt)sample_region.xMin;
i < draw_region.xMax;
i++, x++ )
{
- FT_UInt display_index = j * display->bitmap->width + i;
+ FT_UInt display_index = j * (FT_UInt)display->bitmap->width + i;
float min_dist;
if ( status.nearest_filtering )
{
FT_UInt bitmap_index = ( y / status.scale ) * bitmap->width +
- x / status.scale;
- FT_Byte pixel_value = buffer[bitmap_index];
+ x / status.scale;
+ FT_Byte pixel_value = buffer[bitmap_index];
/* If nearest filtering then simply take the value of the */
diff --git a/src/ftstring.c b/src/ftstring.c
index 57c6326..58075f0 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -217,7 +217,7 @@
outline = &((FT_OutlineGlyph)*glyph)->outline;
- FT_Outline_New( handle->library, points, contours, outline );
+ FT_Outline_New( handle->library, points, (FT_Int)contours, outline );
outline->n_points = outline->n_contours = 0;
FT_Stroker_Export( handle->stroker, outline );
diff --git a/src/ftview.c b/src/ftview.c
index 6c01824..94f8137 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -430,7 +430,7 @@
slot = face->glyph;
error = FT_Palette_Select( face,
- handle->current_font->palette_index,
+ (FT_UShort)handle->current_font->palette_index,
&palette );
if ( error )
palette = NULL;
diff --git a/src/strbuf.c b/src/strbuf.c
index 5b5ed0f..498dc58 100644
--- a/src/strbuf.c
+++ b/src/strbuf.c
@@ -171,9 +171,9 @@
return (int)available;
}
- sb->pos += ret;
+ sb->pos += (unsigned)ret;
- return (int)ret;
+ return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 66991af 2/2: * src/*: Fix clang warnings.,
Werner Lemberg <=