Fix several compiler warnings

This commit is contained in:
Albrecht Schlosser 2023-12-04 17:40:31 +01:00
parent 5a5baca1e2
commit 7c3489061e
5 changed files with 29 additions and 26 deletions

View File

@ -120,9 +120,9 @@ static cairo_surface_t * cairo_create_surface(void * gc, int W, int H) {
cairo_t * Fl::cairo_make_current(void *gc) { cairo_t * Fl::cairo_make_current(void *gc) {
int W=0,H=0; int W=0,H=0;
#if defined(USE_X11) #if defined(USE_X11)
//FIXME X11 get W,H // FIXME X11 get W,H
// gc will be the window handle here // gc will be the window handle here
# warning FIXME get W,H for cairo_make_current(void*) // # warning FIXME get W,H for cairo_make_current(void*)
#elif defined(__APPLE_QUARTZ__) #elif defined(__APPLE_QUARTZ__)
if (fl_window) { if (fl_window) {
W = Fl_Window::current()->w(); W = Fl_Window::current()->w();

View File

@ -1,9 +1,7 @@
// //
// "$Id$"
//
// FLUID undo support for the Fast Light Tool Kit (FLTK). // FLUID undo support for the Fast Light Tool Kit (FLTK).
// //
// Copyright 1998-2010 by Bill Spitzak and others. // Copyright 1998-2023 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this // the file "COPYING" which should have been included with this file. If this
@ -60,8 +58,9 @@ static int undo_paused = 0; // Undo checkpointing paused?
// Return the undo filename // Return the undo filename
static char *undo_filename(int level, char *buf, int bufsize) { static char *undo_filename(int level, char *buf, int bufsize) {
static char undo_path[FL_PATH_MAX] = ""; // Undo path // Undo path. Note: smaller than FL_PATH_MAX to silence compiler
// warning and to prevent potential buffer overflow
static char undo_path[FL_PATH_MAX-32] = "";
if (!undo_path[0]) fluid_prefs.getUserdataPath(undo_path, sizeof(undo_path)); if (!undo_path[0]) fluid_prefs.getUserdataPath(undo_path, sizeof(undo_path));

View File

@ -118,15 +118,15 @@ static const char *find_best_font(const char *fname, int size) {
if (!list) return "fixed"; if (!list) return "fixed";
// search for largest <= font size: // 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; int matchedlength = 32767;
char namebuffer[1024]; // holds scalable font name static char namebuffer[1024]; // holds scalable font name
int found_encoding = 0; int found_encoding = 0;
int m = cnt; if (m<0) m = -m; int m = cnt; if (m<0) m = -m;
for (int n=0; n < m; n++) { for (int n=0; n < m; n++) {
char* thisname = list[n]; char* thisname = list[n];
if (fl_correct_encoding(thisname)) { 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; found_encoding = 1;
} else { } else {
if (found_encoding) continue; if (found_encoding) continue;

View File

@ -124,7 +124,9 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
// collect all the attribute words: // collect all the attribute words:
for (int n = 3; n <= 6; n++) { for (int n = 3; n <= 6; n++) {
// get the next word: // get the next word:
if (*e) e++; x = e; e = fl_font_word(x,1); if (*e) e++;
x = e;
e = fl_font_word(x,1);
int t = attribute(n,x); int t = attribute(n,x);
if (t < 0) { if (t < 0) {
if (o < (f->fontname + ENDOFBUFFER - 1)) *o++ = ' '; if (o < (f->fontname + ENDOFBUFFER - 1)) *o++ = ' ';

View File

@ -116,7 +116,8 @@ void gl_font(int fontid, int size) {
gl_fontsize = fl_fontsize; gl_fontsize = fl_fontsize;
} }
#ifndef __APPLE__ #if !defined(__APPLE__)
#if !(defined(USE_X11) || USE_XFT)
static void get_list(int r) { static void get_list(int r) {
gl_fontsize->glok[r] = 1; gl_fontsize->glok[r] = 1;
#if defined(USE_X11) #if defined(USE_X11)
@ -141,7 +142,8 @@ static void get_list(int r) {
# error unsupported platform # error unsupported platform
#endif #endif
} // get_list } // get_list
#endif #endif // !(defined(USE_X11) || USE_XFT)
#endif // !defined(__APPLE__)
void gl_remove_displaylist_fonts() void gl_remove_displaylist_fonts()
{ {
@ -203,7 +205,7 @@ void gl_draw(const char* str, int n) {
wn = fl_utf8toUtf16(str, n, buf, l); wn = fl_utf8toUtf16(str, n, buf, l);
} }
#if !( defined(USE_X11) || USE_XFT ) #if !(defined(USE_X11) || USE_XFT)
for (unsigned i = 0; i < wn; i++) { for (unsigned i = 0; i < wn; i++) {
unsigned int r; unsigned int r;
r = (buf[i] & 0xFC00) >> 10; r = (buf[i] & 0xFC00) >> 10;