summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordas <das>2008-12-07 16:34:12 (GMT)
committerdas <das>2008-12-07 16:34:12 (GMT)
commitdad5f8c673f46f8a689841cdc0568fff52c5ef87 (patch)
treebc363e25b63d1114e0d291507eb02c7876149aa9 /generic
parent59bd7a0159445f73e970d56b2751c7b9a1924eca (diff)
downloadtk-dad5f8c673f46f8a689841cdc0568fff52c5ef87.zip
tk-dad5f8c673f46f8a689841cdc0568fff52c5ef87.tar.gz
tk-dad5f8c673f46f8a689841cdc0568fff52c5ef87.tar.bz2
Fix potential use of uninitialized variable flagged by clang static analyzer
Diffstat (limited to 'generic')
-rw-r--r--generic/tkCanvPs.c14
-rw-r--r--generic/tkFileFilter.c4
-rw-r--r--generic/tkFont.c4
-rw-r--r--generic/tkListbox.c7
4 files changed, 15 insertions, 14 deletions
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index 866ebba..43fc88a 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCanvPs.c,v 1.24 2008/12/05 16:58:41 das Exp $
+ * RCS: @(#) $Id: tkCanvPs.c,v 1.25 2008/12/07 16:34:12 das Exp $
*/
#include "tkInt.h"
@@ -1255,7 +1255,7 @@ TkPostscriptImage(
* monochrome screen, use gray or monochrome mode instead.
*/
- if (!cdata.color && level == 2) {
+ if (!cdata.color && level >= 2) {
level = 1;
}
@@ -1272,7 +1272,7 @@ TkPostscriptImage(
switch (level) {
case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break;
case 1: bytesPerLine = width; maxWidth = 60000; break;
- case 2: bytesPerLine = 3 * width; maxWidth = 20000; break;
+ default: bytesPerLine = 3 * width; maxWidth = 20000; break;
}
if (bytesPerLine > 60000) {
@@ -1300,7 +1300,7 @@ TkPostscriptImage(
sprintf(buffer, "%d %d 8 matrix {\n<", width, rows);
Tcl_AppendResult(interp, buffer, NULL);
break;
- case 2:
+ default:
sprintf(buffer, "%d %d 8 matrix {\n<", width, rows);
Tcl_AppendResult(interp, buffer, NULL);
break;
@@ -1362,7 +1362,7 @@ TkPostscriptImage(
}
}
break;
- case 2:
+ default:
/*
* Finally, color mode. Here, just output the red, green, and
* blue values directly.
@@ -1388,7 +1388,7 @@ TkPostscriptImage(
switch (level) {
case 0: case 1:
sprintf(buffer, ">\n} image\n"); break;
- case 2:
+ default:
sprintf(buffer, ">\n} false 3 colorimage\n"); break;
}
Tcl_AppendResult(interp, buffer, NULL);
@@ -1587,7 +1587,7 @@ Tk_PostscriptPhoto(
switch (colorLevel) {
case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break;
case 1: bytesPerLine = width; maxWidth = 60000; break;
- case 2: bytesPerLine = 3 * width; maxWidth = 20000; break;
+ default: bytesPerLine = 3 * width; maxWidth = 20000; break;
}
if (bytesPerLine > 60000) {
Tcl_ResetResult(interp);
diff --git a/generic/tkFileFilter.c b/generic/tkFileFilter.c
index 94cdbcd..4e355d4 100644
--- a/generic/tkFileFilter.c
+++ b/generic/tkFileFilter.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkFileFilter.c,v 1.11 2008/04/27 22:38:56 dkf Exp $
+ * RCS: @(#) $Id: tkFileFilter.c,v 1.12 2008/12/07 16:34:12 das Exp $
*/
#include "tkInt.h"
@@ -338,7 +338,7 @@ AddClause(
globPtr->next = NULL;
}
}
- if (ostypeCount > 0 && ostypeList != NULL) {
+ if (ostypeList != NULL && ostypeCount > 0) {
if (macRoman == NULL) {
macRoman = Tcl_GetEncoding(NULL, "macRoman");
}
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 961feac..0b67f56 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkFont.c,v 1.50 2008/11/22 20:05:32 patthoyts Exp $
+ * RCS: @(#) $Id: tkFont.c,v 1.51 2008/12/07 16:34:12 das Exp $
*/
#include "tkInt.h"
@@ -2675,7 +2675,7 @@ Tk_CharBbox(
{
TextLayout *layoutPtr;
LayoutChunk *chunkPtr;
- int i, x, w;
+ int i, x = 0, w;
Tk_Font tkfont;
TkFont *fontPtr;
const char *end;
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index 72141b8..d15246c 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkListbox.c,v 1.52 2008/11/08 22:52:29 dkf Exp $
+ * RCS: @(#) $Id: tkListbox.c,v 1.53 2008/12/07 16:34:12 das Exp $
*/
#include "default.h"
@@ -1336,8 +1336,6 @@ ListboxYviewSubCmd(
} else {
type = Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count);
switch (type) {
- case TK_SCROLL_ERROR:
- return TCL_ERROR;
case TK_SCROLL_MOVETO:
index = (int) (listPtr->nElements*fraction + 0.5);
break;
@@ -1351,6 +1349,9 @@ ListboxYviewSubCmd(
case TK_SCROLL_UNITS:
index = listPtr->topIndex + count;
break;
+ case TK_SCROLL_ERROR:
+ default:
+ return TCL_ERROR;
}
ChangeListboxView(listPtr, index);
}