Skip to content
Browse files

Avoid a compiler warning by moving more things within #ifdef

This is a warning from the compiler but there is not actually any
chance of using background_pixmap uninitialised.

clang++ -O2 -Wall -I. -Ilinux/  -c -o xwin.o xwin.cc
xwin.cc:117:46: warning: variable 'background_pixmap' is uninitialized when used
      here [-Wuninitialized]
        XSetWindowBackgroundPixmap(display_,window_,background_pixmap);
                                                    ^~~~~~~~~~~~~~~~~
xwin.cc:82:34: note: initialize the variable 'background_pixmap' to silence this
      warning
  Pixmap               background_pixmap;
                                        ^
                                         = 0
1 warning generated.
  • Loading branch information...
1 parent c472d9f commit 8ff63a1bfc0030d52766927449dad9c0fc4a986a Mark Hills committed Mar 6, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 xwin.cc
View
12 xwin.cc
@@ -79,15 +79,11 @@ XWin::~XWin( void ){
void XWin::init( int argc, char **argv ){
XGCValues gcv;
XSetWindowAttributes xswa;
- Pixmap background_pixmap;
- int doPixmap = 0;
setFont();
setColors();
getGeometry();
-#ifdef HAVE_XPM
- doPixmap=getPixmap(&background_pixmap);
-#endif
+
borderwidth_ = atoi(getResourceOrUseDefault("borderwidth", "1"));
window_ = XCreateSimpleWindow(display_, DefaultRootWindow(display_),
@@ -112,11 +108,15 @@ void XWin::init( int argc, char **argv ){
XChangeWindowAttributes(display_, window_,
(CWColormap | CWBitGravity), &xswa);
+#ifdef HAVE_XPM
+ Pixmap background_pixmap;
+
// If there is a pixmap file, set it as the background
- if(doPixmap)
+ if(getPixmap(&background_pixmap))
{
XSetWindowBackgroundPixmap(display_,window_,background_pixmap);
}
+#endif
// Do transparency if requested
if(isResourceTrue("transparent"))

0 comments on commit 8ff63a1

Please sign in to comment.
Something went wrong with that request. Please try again.