From 3ceafc3e134069ecd46df6482e8e7d4b5a7051c3 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 28 Nov 2021 12:49:54 -0800 Subject: [PATCH 1/3] PrintProperty: replace sprintf with snprintf Signed-off-by: Alan Coopersmith --- xlsfonts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xlsfonts.c b/xlsfonts.c index 52d3807..2d8d3f2 100644 --- a/xlsfonts.c +++ b/xlsfonts.c @@ -497,9 +497,8 @@ PrintProperty(XFontProp * prop) atom = XGetAtomName(dpy, prop->name); if (!atom) { + snprintf(nosuch, sizeof(nosuch), "No such atom = %ld", prop->name); atom = nosuch; - nosuch[0] = '\0'; - (void) sprintf(atom, "No such atom = %ld", prop->name); } printf(" %s", atom); -- GitLab From 7b84a6ffa8bae2dd9fe8cb1c8bc5b0b198584d8d Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 28 Nov 2021 12:58:35 -0800 Subject: [PATCH 2/3] Clear -Wsign-compare warnings from gcc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xlsfonts.c:560:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] i <= fs->max_char_or_byte2; i++, cs++) { ^~ xlsfonts.c: In function ‘print_character_metrics’: xlsfonts.c:611:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (j = info->min_byte1; j <= info->max_byte1; j++) { ^~ xlsfonts.c:613:45: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (i = info->min_char_or_byte2; i <= info->max_char_or_byte2; i++) { ^~ Signed-off-by: Alan Coopersmith --- xlsfonts.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xlsfonts.c b/xlsfonts.c index 2d8d3f2..d5163ae 100644 --- a/xlsfonts.c +++ b/xlsfonts.c @@ -532,7 +532,6 @@ PrintProperty(XFontProp * prop) static void ComputeFontType(XFontStruct *fs) { - int i; Bool char_cell = True; const char *reason = NULL; XCharStruct *cs; @@ -545,7 +544,7 @@ ComputeFontType(XFontStruct *fs) } if (awatom) { - for (i = 0; i < fs->n_properties; i++) { + for (int i = 0; i < fs->n_properties; i++) { if (fs->properties[i].name == awatom && (fs->max_bounds.width * 10) != fs->properties[i].card32) { char_cell = False; @@ -556,6 +555,7 @@ ComputeFontType(XFontStruct *fs) } if (fs->per_char) { + unsigned int i; for (i = fs->min_char_or_byte2, cs = fs->per_char; i <= fs->max_char_or_byte2; i++, cs++) { if (cs->width == 0) @@ -603,7 +603,7 @@ static void print_character_metrics(register XFontStruct *info) { register XCharStruct *pc = info->per_char; - register int i, j; + unsigned int i, j; unsigned n, saven; printf(" character metrics:\n"); -- GitLab From a03ab7e51a9f2239c698749df401cedf8386e721 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 28 Nov 2021 13:05:36 -0800 Subject: [PATCH 3/3] Clear -Wshadow warning from gcc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xlsfonts.c: In function ‘do_query_font’: xlsfonts.c:628:24: warning: declaration of ‘dpy’ shadows a global declaration [-Wshadow] do_query_font(Display *dpy, char *name) ^~~ In file included from xlsfonts.c:37:0: dsimple.h:53:17: note: shadowed declaration is here extern Display *dpy; /* The current display */ ^~~ Signed-off-by: Alan Coopersmith --- xlsfonts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xlsfonts.c b/xlsfonts.c index d5163ae..b834637 100644 --- a/xlsfonts.c +++ b/xlsfonts.c @@ -625,10 +625,10 @@ print_character_metrics(register XFontStruct *info) } static void -do_query_font(Display *dpy, char *name) +do_query_font(Display *display, char *name) { register int i; - register XFontStruct *info = XLoadQueryFont(dpy, name); + register XFontStruct *info = XLoadQueryFont(display, name); if (!info) { fprintf(stderr, "%s: unable to get info about font \"%s\"\n", -- GitLab