From a73a14347db54693fa486e2ebf400d7ce26231e6 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 4 Dec 2023 16:50:23 +0100 Subject: [PATCH] Fix compiler warnings fluid/code.cxx: unused variable src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx: function may return address of local variable [-Wreturn-local-addr] --- fluid/code.cxx | 2 -- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx | 9 +++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fluid/code.cxx b/fluid/code.cxx index bfbec1086..192e21149 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -131,8 +131,6 @@ int write_strings(const Fl_String &filename) { } if (w->tooltip()) { - const char *s; - fputs("msgid \"", fp); write_escaped_strings(fp, w->tooltip()); fputs("\"\n", fp); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx index 94d013b3f..8ba7fb908 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx @@ -452,21 +452,22 @@ int fl_correct_encoding(const char* name) { static const char *find_best_font(const char *fname, int size) { int cnt; static char **list = NULL; -// locate or create an Fl_Font_Descriptor for a given Fl_Fontdesc and size: + // note: namebuffer must be static: its address may be returned to caller + static char namebuffer[1024]; // holds scalable font name + // locate or create an Fl_Font_Descriptor for a given Fl_Fontdesc and size: if (list) XFreeFontNames(list); list = XListFonts(fl_display, fname, 100, &cnt); if (!list) return "fixed"; // search for largest <= font size: - char* name = list[0]; int ptsize = 0; // best one found so far + char* name = list[0]; int ptsize = 0; // best one found so far int matchedlength = 32767; - char namebuffer[1024]; // holds scalable font name int found_encoding = 0; int m = cnt; if (m<0) m = -m; for (int n=0; n < m; n++) { char* thisname = list[n]; if (fl_correct_encoding(thisname)) { - if (!found_encoding) ptsize = 0; // force it to choose this + if (!found_encoding) ptsize = 0; // force it to choose this found_encoding = 1; } else { if (found_encoding) continue;