1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

Fix uninitialized vars

Initialized variables that are conditionally set. In particular, this
construct is dangerous:
  void *p;
  if (something) p = couldReturnNull();
  if (!p) p = fallbackFunction();
This commit is contained in:
Brad Jorsch
2010-04-08 14:43:52 -04:00
committed by Carlos R. Mafra
parent bbf3635590
commit 12de2f319e
6 changed files with 13 additions and 7 deletions

View File

@@ -544,7 +544,7 @@ static Pixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int
int style; int style;
RColor rcolor2; RColor rcolor2;
int i; int i;
RImage *grad, *timage; RImage *grad, *timage = NULL;
char *path; char *path;
switch (toupper(type[1])) { switch (toupper(type[1])) {

View File

@@ -22,6 +22,7 @@
#include "WPrefs.h" #include "WPrefs.h"
#include <unistd.h> #include <unistd.h>
#include <assert.h>
typedef struct _Panel { typedef struct _Panel {
WMBox *box; WMBox *box;
@@ -131,6 +132,8 @@ static void browseForFile(WMWidget * w, void *data)
_Panel *panel = (_Panel *) data; _Panel *panel = (_Panel *) data;
WMFilePanel *filePanel; WMFilePanel *filePanel;
assert(w == panel->icoaB || w == panel->pixaB);
filePanel = WMGetOpenPanel(WMWidgetScreen(w)); filePanel = WMGetOpenPanel(WMWidgetScreen(w));
WMSetFilePanelCanChooseFiles(filePanel, False); WMSetFilePanelCanChooseFiles(filePanel, False);
@@ -147,7 +150,7 @@ static void browseForFile(WMWidget * w, void *data)
len--; len--;
} }
if (len > 0) { if (len > 0) {
WMList *lPtr; WMList *lPtr = NULL;
int i; int i;
if (w == panel->icoaB) if (w == panel->icoaB)

View File

@@ -404,7 +404,7 @@ char *ShrinkString(WMFont * font, char *string, int width)
char *FindImage(char *paths, char *file) char *FindImage(char *paths, char *file)
{ {
char *tmp, *path; char *tmp, *path = NULL;
tmp = strrchr(file, ':'); tmp = strrchr(file, ':');
if (tmp) { if (tmp) {

View File

@@ -148,6 +148,7 @@ static int getMWMHints(Window window, MWMHints *mwmhints)
if (!data) if (!data)
return 0; return 0;
mwmhints->flags = 0;
if (count >= 4) { if (count >= 4) {
mwmhints->flags = data[0]; mwmhints->flags = data[0];
mwmhints->functions = data[1]; mwmhints->functions = data[1];

View File

@@ -181,7 +181,7 @@ static Bool isFontOption(char *option)
/* XXX: is almost like WINGs/wcolodpanel.c:fetchFile() */ /* XXX: is almost like WINGs/wcolodpanel.c:fetchFile() */
void copyFile(char *dir, char *file) void copyFile(char *dir, char *file)
{ {
FILE *src, *dst; FILE *src = NULL, *dst = NULL;
size_t nread, nwritten, len; size_t nread, nwritten, len;
char buf[4096]; char buf[4096];
struct stat st; struct stat st;
@@ -230,7 +230,9 @@ void copyFile(char *dir, char *file)
RETRY( fclose(dst) ) RETRY( fclose(dst) )
err: err:
if (src) {
RETRY( fclose(src) ) RETRY( fclose(src) )
}
wfree(dstpath); wfree(dstpath);
return; return;
} }

View File

@@ -471,7 +471,7 @@ BackgroundTexture *parseTexture(RContext * rc, char *text)
XColor color; XColor color;
Pixmap pixmap = None; Pixmap pixmap = None;
RImage *image = NULL; RImage *image = NULL;
int iwidth, iheight; int iwidth = 0, iheight = 0;
RColor rcolor; RColor rcolor;
GETSTRORGOTO(val, tmp, 1, error); GETSTRORGOTO(val, tmp, 1, error);
@@ -879,7 +879,7 @@ void helperLoop(RContext * rc)
memset(textures, 0, WORKSPACE_COUNT * sizeof(BackgroundTexture *)); memset(textures, 0, WORKSPACE_COUNT * sizeof(BackgroundTexture *));
while (1) { while (1) {
int workspace; int workspace = -1;
/* get length of message */ /* get length of message */
if (readmsg(0, buffer, 4) < 0) { if (readmsg(0, buffer, 4) < 0) {