[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master a4db11c: Fix compilation warnings (#58257).
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master a4db11c: Fix compilation warnings (#58257). |
Date: |
Fri, 1 May 2020 09:16:46 -0400 (EDT) |
branch: master
commit a4db11c110df7c34abc01cbab197e48efc434524
Author: David Turner <address@hidden>
Commit: Werner Lemberg <address@hidden>
Fix compilation warnings (#58257).
* graph/x11/grx11.c (gr_x11_surface_listen_event): Change return
type of to match the expected type.
* src/compos.c, src/ftchkwd.c, src/ftdump.c, src/ftlint.c,
src/ftmemchk.c, src/ftsbit.c, src/fttimer.c, src/fttry.c (main):
Remove problematic uses of `strncpy' and replace them with
`snprintf', which takes the size of the target buffer.
Remove un-needed uses of the `alt_filename' array.
---
ChangeLog | 14 ++++++++++++++
graph/x11/grx11.c | 4 +++-
src/compos.c | 17 +++++------------
src/ftchkwd.c | 16 ++++------------
src/ftdump.c | 16 ++++------------
src/ftlint.c | 17 +++++------------
src/ftmemchk.c | 17 +++++------------
src/ftsbit.c | 14 ++++----------
src/fttimer.c | 14 ++------------
src/fttry.c | 13 ++-----------
10 files changed, 48 insertions(+), 94 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c4d128b..6f9e042 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2020-05-01 David Turner <address@hidden>
+
+ Fix compilation warnings (#58257).
+
+ * graph/x11/grx11.c (gr_x11_surface_listen_event): Change return
+ type of to match the expected type.
+
+ * src/compos.c, src/ftchkwd.c, src/ftdump.c, src/ftlint.c,
+ src/ftmemchk.c, src/ftsbit.c, src/fttimer.c, src/fttry.c (main):
+ Remove problematic uses of `strncpy' and replace them with
+ `snprintf', which takes the size of the target buffer.
+
+ Remove un-needed uses of the `alt_filename' array.
+
2020-04-16 Anuj Verma <address@hidden>
* Makefile (FT_INCLUDES): Remove configuration directory since
diff --git a/graph/x11/grx11.c b/graph/x11/grx11.c
index c923e0a..9bca06b 100644
--- a/graph/x11/grx11.c
+++ b/graph/x11/grx11.c
@@ -1148,7 +1148,7 @@ typedef unsigned long uint32;
}
- static void
+ static int
gr_x11_surface_listen_event( grX11Surface* surface,
int event_mask,
grEvent* grevent )
@@ -1237,6 +1237,8 @@ typedef unsigned long uint32;
Set_Key:
grevent->type = gr_key_down;
grevent->key = grkey;
+
+ return 1;
}
diff --git a/src/compos.c b/src/compos.c
index 46ee2ae..e358c71 100644
--- a/src/compos.c
+++ b/src/compos.c
@@ -65,7 +65,6 @@
int i, file_index;
unsigned int id;
char filename[1024 + 4];
- char alt_filename[1024 + 4];
char* execname;
char* fname;
@@ -90,19 +89,13 @@
i--;
}
- filename[1024] = '\0';
- alt_filename[1024] = '\0';
-
- strncpy( filename, fname, 1024 );
- strncpy( alt_filename, fname, 1024 );
-
#ifndef macintosh
- if ( i >= 0 )
- {
- strncpy( filename + strlen( filename ), ".ttf", 4 );
- strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
- }
+ snprintf( filename, sizeof ( filename ), "%s%s", fname,
+ ( i >= 0 ? ".ttf" : "" ) );
+#else
+ snprintf( filename, sizeof ( filename ), "%s", fname );
#endif
+
i = strlen( filename );
fname = filename;
diff --git a/src/ftchkwd.c b/src/ftchkwd.c
index 7673847..176ecb8 100644
--- a/src/ftchkwd.c
+++ b/src/ftchkwd.c
@@ -119,7 +119,6 @@
int i, file_index;
char filename[1024 + 4];
- char alt_filename[1024 + 4];
char* execname;
char* fname;
@@ -160,18 +159,11 @@
i--;
}
- filename[1024] = '\0';
- alt_filename[1024] = '\0';
-
- strncpy( filename, fname, 1024 );
- strncpy( alt_filename, fname, 1024 );
-
#ifndef macintosh
- if ( i >= 0 )
- {
- strncpy( filename + strlen( filename ), ".ttf", 4 );
- strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
- }
+ snprintf( filename, sizeof ( filename ), "%s%s", fname,
+ ( i >= 0 ? ".ttf" : "" ) );
+#else
+ snprintf( filename, sizeof ( filename ), "%s", fname );
#endif
/* Load face */
diff --git a/src/ftdump.c b/src/ftdump.c
index b2541af..27318c7 100644
--- a/src/ftdump.c
+++ b/src/ftdump.c
@@ -884,7 +884,6 @@
{
int i, file;
char filename[1024];
- char alt_filename[1024];
char* execname;
int num_faces;
int option;
@@ -962,12 +961,6 @@
file = 0;
- strncpy( filename, argv[file], 1019 );
- strncpy( alt_filename, argv[file], 1019 );
-
- filename[1019] = '\0';
- alt_filename[1019] = '\0';
-
/* try to load the file name as is, first */
error = FT_New_Face( library, argv[file], 0, &face );
if ( !error )
@@ -982,11 +975,10 @@
i--;
}
- if ( i >= 0 )
- {
- strncpy( filename + strlen( filename ), ".ttf", 5 );
- strncpy( alt_filename + strlen( alt_filename ), ".ttc", 5 );
- }
+ snprintf( filename, sizeof ( filename ), "%s%s", argv[file],
+ ( i >= 0 ? ".ttf" : "" ) );
+#else
+ snprintf( filename, sizeof ( filename ), "%s", argv[file] );
#endif
/* Load face */
diff --git a/src/ftlint.c b/src/ftlint.c
index 02bb4e6..0905073 100644
--- a/src/ftlint.c
+++ b/src/ftlint.c
@@ -63,7 +63,6 @@
int i, file_index;
unsigned int id;
char filename[1024];
- char alt_filename[1024];
char* execname;
char* fname;
@@ -110,19 +109,13 @@
i--;
}
- strncpy( filename, fname, 1019 );
- strncpy( alt_filename, fname, 1019 );
-
- filename[1019] = '\0';
- alt_filename[1019] = '\0';
-
#ifndef macintosh
- if ( i >= 0 )
- {
- strncpy( filename + strlen( filename ), ".ttf", 5 );
- strncpy( alt_filename + strlen( alt_filename ), ".ttc", 5 );
- }
+ snprintf( filename, sizeof ( filename ), "%s%s", fname,
+ ( i >= 0 ) ? ".ttf" : "" );
+#else
+ snprintf( filename, sizeof ( filename ), "%s", fname );
#endif
+
i = (int)strlen( filename );
fname = filename;
diff --git a/src/ftmemchk.c b/src/ftmemchk.c
index 79621f8..ea8a836 100644
--- a/src/ftmemchk.c
+++ b/src/ftmemchk.c
@@ -228,7 +228,6 @@ int main( int argc, char** argv )
int i, file_index;
unsigned int id;
char filename[1024 + 4];
- char alt_filename[1024 + 4];
char* execname;
char* fname;
@@ -261,19 +260,13 @@ int main( int argc, char** argv )
i--;
}
- filename[1024] = '\0';
- alt_filename[1024] = '\0';
-
- strncpy( filename, fname, 1024 );
- strncpy( alt_filename, fname, 1024 );
-
#ifndef macintosh
- if ( i >= 0 )
- {
- strncpy( filename + strlen( filename ), ".ttf", 4 );
- strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
- }
+ snprintf( filename, sizeof ( filename ), "%s%s", fname,
+ ( i >= 0 ) ? ".ttf" : "" );
+#else
+ snprintf( filename, sizeof ( filename ), "%s", fname );
#endif
+
i = strlen( filename );
fname = filename;
diff --git a/src/ftsbit.c b/src/ftsbit.c
index 8404aff..2acee39 100644
--- a/src/ftsbit.c
+++ b/src/ftsbit.c
@@ -195,17 +195,11 @@
i--;
}
- filename[1024] = '\0';
- alt_filename[1024] = '\0';
+ snprintf( filename, sizeof ( filename ), "%s%s", fname,
+ ( i >= 0 ) ? ".ttf" : "" );
- strncpy( filename, fname, 1024 );
- strncpy( alt_filename, fname, 1024 );
-
- if ( i >= 0 )
- {
- strncpy( filename + strlen( filename ), ".ttf", 4 );
- strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
- }
+ snprintf( alt_filename, sizeof ( alt_filename ), "%s%s", fname,
+ ( i >= 0 ) ? ".ttc" : "" );
/* Load face */
error = FT_New_Resource( engine, filename, &resource );
diff --git a/src/fttimer.c b/src/fttimer.c
index fc60360..bf67a4b 100644
--- a/src/fttimer.c
+++ b/src/fttimer.c
@@ -163,7 +163,6 @@
{
int i, total, base, rendered_glyphs;
char filename[1024 + 4];
- char alt_filename[1024 + 4];
long t, t0, tz0;
@@ -222,17 +221,8 @@
i--;
}
- filename[1024] = '\0';
- alt_filename[1024] = '\0';
-
- strncpy( filename, argv[1], 1024 );
- strncpy( alt_filename, argv[1], 1024 );
-
- if ( i >= 0 )
- {
- strncpy( filename + strlen( filename ), ".ttf", 4 );
- strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
- }
+ snprintf( filename, sizeof ( filename ), "%s%s", argv[1],
+ ( i >= 0 ) ? ".ttf" : "" );
/* Initialize engine */
diff --git a/src/fttry.c b/src/fttry.c
index dda9075..a7a2a69 100644
--- a/src/fttry.c
+++ b/src/fttry.c
@@ -67,7 +67,6 @@
{
int i, file_index, glyph_index;
char filename[1024 + 4];
- char alt_filename[1024 + 4];
char* execname;
char* fname;
int load_unscaled = 0;
@@ -108,17 +107,9 @@
i--;
}
- filename[1024] = '\0';
- alt_filename[1024] = '\0';
+ snprintf( filename, sizeof ( filename ), "%s%s", fname,
+ ( i >= 0 ) ? ".ttf" : "" );
- strncpy( filename, fname, 1024 );
- strncpy( alt_filename, fname, 1024 );
-
- if ( i >= 0 )
- {
- strncpy( filename + strlen( filename ), ".ttf", 4 );
- strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
- }
i = strlen( filename );
fname = filename;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master a4db11c: Fix compilation warnings (#58257).,
Werner LEMBERG <=