summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2020-01-15 21:23:26 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-01-15 21:23:26 +0100
commitdfaab4ae9004fa636bb11fdc4846a11a16e81ebb (patch)
treef958ef65e4104c15f66a3e144776f41a95385f0e /src/drivers
parent3265d439f351d3a4d48bb1f99047f24134f1e5aa (diff)
Fix uninitialized vars in calls to fl_clip_box() (issue #6)
The main fixes are only to avoid static code analyzer warnings reported in issue #5, but there are also minor bug fixes included. These bug fixes are more of theoretical concerns though. Close #6.
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Android/Fl_Android_Window_Driver.cxx8
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx6
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx4
-rw-r--r--src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx3
-rw-r--r--src/drivers/PostScript/Fl_PostScript.cxx24
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx5
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.cxx5
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx6
8 files changed, 33 insertions, 28 deletions
diff --git a/src/drivers/Android/Fl_Android_Window_Driver.cxx b/src/drivers/Android/Fl_Android_Window_Driver.cxx
index 5781c0361..7a3e276fd 100644
--- a/src/drivers/Android/Fl_Android_Window_Driver.cxx
+++ b/src/drivers/Android/Fl_Android_Window_Driver.cxx
@@ -3,7 +3,7 @@
//
// Definition of Android window driver.
//
-// Copyright 2018 by Bill Spitzak and others.
+// Copyright 2018-2020 by Bill Spitzak and others.
//
// 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
@@ -510,7 +510,8 @@ void Fl_WinAPI_Window_Driver::flush_double()
fl_end_offscreen();
}
- int X,Y,W,H; fl_clip_box(0,0,w(),h(),X,Y,W,H);
+ int X = 0, Y = 0, W = 0, H = 0;
+ fl_clip_box(0, 0, w(), h(), X, Y, W, H);
if (other_xid) fl_copy_offscreen(X, Y, W, H, other_xid, X, Y);
}
@@ -540,7 +541,8 @@ void Fl_WinAPI_Window_Driver::flush_overlay()
}
if (eraseoverlay) fl_clip_region(0);
- int X, Y, W, H; fl_clip_box(0, 0, w(), h(), X, Y, W, H);
+ int X = 0, Y = 0, W = 0, H = 0;
+ fl_clip_box(0, 0, w(), h(), X, Y, W, H);
if (other_xid) fl_copy_offscreen(X, Y, W, H, other_xid, X, Y);
if (overlay() == oWindow) oWindow->draw_overlay();
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
index a4f4a472c..0533b3b5f 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
@@ -3,7 +3,7 @@
//
// Windows image drawing code for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// 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
@@ -125,8 +125,8 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
if (!linedelta) linedelta = W*fl_abs(delta);
- int x, y, w, h;
- fl_clip_box(X,Y,W,H,x,y,w,h);
+ int x = 0, y = 0, w = 0, h = 0;
+ fl_clip_box(X, Y, W, H, x, y, w, h);
if (w<=0 || h<=0) return;
if (buf) buf += (x-X)*delta + (y-Y)*linedelta;
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
index 2af56c55c..a0ce203ea 100644
--- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
@@ -3,7 +3,7 @@
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2017 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// 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
@@ -172,7 +172,7 @@ void Fl_OpenGL_Graphics_Driver::push_clip(int x, int y, int w, int h) {
int Fl_OpenGL_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) {
// TODO: implement OpenGL clipping
- X = x; Y = y; W = w, H = h;
+ X = x; Y = y; W = w; H = h;
return 0;
}
diff --git a/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx b/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx
index e11c13437..ace311323 100644
--- a/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx
+++ b/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx
@@ -3,7 +3,7 @@
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2016 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// 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
@@ -195,6 +195,7 @@ void Fl_Pico_Graphics_Driver::push_clip(int x, int y, int w, int h)
int Fl_Pico_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
{
+ X = x; Y = y; W = w; H = h;
return 0;
}
diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx
index 1b6fed13e..5e7f6b4e0 100644
--- a/src/drivers/PostScript/Fl_PostScript.cxx
+++ b/src/drivers/PostScript/Fl_PostScript.cxx
@@ -3,7 +3,7 @@
//
// Classes Fl_PostScript_File_Device and Fl_PostScript_Graphics_Driver for the Fast Light Tool Kit (FLTK).
//
-// Copyright 2010-2016 by Bill Spitzak and others.
+// Copyright 2010-2020 by Bill Spitzak and others.
//
// 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
@@ -1341,16 +1341,16 @@ void Fl_PostScript_Graphics_Driver::pop_clip() {
recover();
}
-int Fl_PostScript_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H){
- if(!clip_){
- X=x;Y=y;W=w;H=h;
+int Fl_PostScript_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) {
+ if (!clip_) {
+ X = x; Y = y; W = w; H = h;
return 1;
}
- if(clip_->w < 0){
- X=x;Y=y;W=w;H=h;
+ if (clip_->w < 0) {
+ X = x; Y = y; W = w; H = h;
return 1;
}
- int ret=0;
+ int ret = 0;
if (x > (X=clip_->x)) {X=x; ret=1;}
if (y > (Y=clip_->y)) {Y=y; ret=1;}
if ((x+w) < (clip_->x+clip_->w)) {
@@ -1377,12 +1377,12 @@ int Fl_PostScript_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X,
return ret;
}
-int Fl_PostScript_Graphics_Driver::not_clipped(int x, int y, int w, int h){
- if(!clip_) return 1;
- if(clip_->w < 0) return 1;
- int X, Y, W, H;
+int Fl_PostScript_Graphics_Driver::not_clipped(int x, int y, int w, int h) {
+ if (!clip_) return 1;
+ if (clip_->w < 0) return 1;
+ int X = 0, Y = 0, W = 0, H = 0;
clip_box(x, y, w, h, X, Y, W, H);
- if(W) return 1;
+ if (W) return 1;
return 0;
}
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
index 78379712f..fb449754e 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
@@ -3,7 +3,7 @@
//
// Definition of Apple Cocoa window driver.
//
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// 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
@@ -334,7 +334,8 @@ void Fl_WinAPI_Window_Driver::flush_double()
fl_graphics_driver->gc(sgc);
#endif
}
- int X,Y,W,H; fl_clip_box(0,0,w(),h(),X,Y,W,H);
+ int X = 0, Y = 0, W = 0, H = 0;
+ fl_clip_box(0, 0, w(), h(), X, Y, W, H);
if (other_xid) fl_copy_offscreen(X, Y, W, H, other_xid, X, Y);
}
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx
index 1de2e5297..2ea16bf70 100644
--- a/src/drivers/X11/Fl_X11_Window_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx
@@ -3,7 +3,7 @@
//
// Definition of X11 window driver.
//
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// 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
@@ -234,7 +234,8 @@ void Fl_X11_Window_Driver::flush_double(int erase_overlay)
fl_window = i->xid;
}
if (erase_overlay) fl_clip_region(0);
- int X,Y,W,H; fl_clip_box(0,0,w(),h(),X,Y,W,H);
+ int X = 0, Y = 0, W = 0, H = 0;
+ fl_clip_box(0, 0, w(), h(), X, Y, W, H);
if (other_xid) fl_copy_offscreen(X, Y, W, H, other_xid, X, Y);
}
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
index 688457a24..8fed7834b 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
@@ -3,7 +3,7 @@
//
// Image drawing routines for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// 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
@@ -474,8 +474,8 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
{
if (!linedelta) linedelta = W*abs(delta);
- int dx, dy, w, h;
- fl_clip_box(X,Y,W,H,dx,dy,w,h);
+ int dx = 0, dy = 0, w = 0, h = 0;
+ fl_clip_box(X, Y, W, H, dx, dy, w, h);
if (w<=0 || h<=0) return;
dx -= X;
dy -= Y;