1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
Description: Patch initializes all variables for which GCC gave warnings
about unitialized or maybe unitialized variables.
Author: Sergei Golovan
Last-Modified: Wed, 09 Jul 2014 19:17:02 +0400
--- a/generic/bltArrayObj.c
+++ b/generic/bltArrayObj.c
@@ -69,6 +69,7 @@
}
if (nElem%2) {
if (interp != NULL) {
+ string = Tcl_GetString(objPtr);
Tcl_AppendResult(interp, "odd length: ", string, 0);
}
return TCL_ERROR;
--- a/generic/bltBgexec.c
+++ b/generic/bltBgexec.c
@@ -559,6 +559,7 @@
*lengthPtr = length;
return string;
}
+ *lengthPtr = length;
return NULL;
}
@@ -603,6 +604,7 @@
return string;
}
}
+ *lengthPtr = 0;
return NULL;
}
/*
--- a/generic/bltTreeCmd.c
+++ b/generic/bltTreeCmd.c
@@ -8086,7 +8086,7 @@
Blt_TreeKeySearch keyIter;
int vobjc, kobjc, i, result = TCL_OK, len, cnt = 0, isar;
int nobreak = 0, noupdate = 0, unset = 0, init = 0, aLen;
- char *var, *string, *aName, *aPat = NULL;
+ char *var, *string, *aName = NULL, *aPat = NULL;
int klen, kl, j;
int *keySet = NULL;
unsigned int inode;
--- a/generic/bltVector.c
+++ b/generic/bltVector.c
@@ -1896,7 +1896,7 @@
return TCL_OK;
}
for (i=2; i<objc; i+=2) {
- int option, *ovar;
+ int option, *ovar = NULL;
if (Tcl_GetIndexFromObj(interp, objv[i], optionArr, "option",
0, &option) != TCL_OK) {
return TCL_OK;
--- a/generic/bltGrAxis.c
+++ b/generic/bltGrAxis.c
@@ -1426,7 +1426,15 @@
nMajor = nMinor = 0;
majorStep = minorStep = 0.0;
- if (min < max) {
+ if (min > max) {
+ double m;
+ m = min;
+ min = max;
+ max = m;
+ } else if (min == max) {
+ max = min + 1.0;
+ }
+ /* if (min < max) { */
min = (min != 0.0) ? log10(FABS(min)) : 0.0;
max = (max != 0.0) ? log10(FABS(max)) : 1.0;
@@ -1474,7 +1482,7 @@
(DEFINED(axisPtr->reqMax)))) {
tickMax = max;
}
- }
+ /* } */
axisPtr->majorSweep.step = majorStep;
axisPtr->majorSweep.initial = floor(tickMin);
axisPtr->majorSweep.nSteps = nMajor;
@@ -1556,7 +1564,15 @@
nTicks = 0;
tickMin = tickMax = 0.0;
- if (min < max) {
+ if (min > max) {
+ double m;
+ m = min;
+ min = max;
+ max = m;
+ } else if (min == max) {
+ max = min + 1.0;
+ }
+ /* if (min < max) { */
range = max - min;
/* Calculate the major tick stepping. */
@@ -1578,7 +1594,7 @@
axisMax = tickMax = ceil(max / step) * step + 0.0;
nTicks = Round((tickMax - tickMin) / step) + 1;
- }
+ /* } */
axisPtr->majorSweep.step = step;
axisPtr->majorSweep.initial = tickMin;
axisPtr->majorSweep.nSteps = nTicks;
--- a/generic/bltGrLine.c
+++ b/generic/bltGrLine.c
@@ -3085,8 +3085,9 @@
register Point2D *pointPtr, *endPtr;
int i;
- i = -1; /* Suppress compiler warning. */
+ i = searchPtr->index;
minDist = searchPtr->dist;
+ closest = searchPtr->point;
for (linkPtr = Blt_ChainFirstLink(linePtr->traces); linkPtr != NULL;
linkPtr = Blt_ChainNextLink(linkPtr)) {
tracePtr = Blt_ChainGetValue(linkPtr);
@@ -3140,8 +3141,9 @@
int i;
register Segment2D *s;
- i = 0;
+ i = searchPtr->index;
minDist = searchPtr->dist;
+ closest = searchPtr->point;
s = linePtr->strips;
for (count = 0; count < linePtr->nStrips; count++, s++) {
dist = (*distProc)(searchPtr->x, searchPtr->y, &(s->p), &(s->q), &b);
--- a/generic/bltBeep.c
+++ b/generic/bltBeep.c
@@ -58,9 +58,7 @@
argv[0], " ?volumePercent?\"", (char *)NULL);
return TCL_ERROR;
}
- if (argc == 1) {
- percent = 50; /* Default setting */
- } else if (argc == 2) {
+ if (argc == 2) {
if (Tcl_GetInt(interp, argv[1], &percent) != TCL_OK) {
return TCL_ERROR;
}
@@ -69,6 +67,8 @@
argv[1], "\"", (char *)NULL);
return TCL_ERROR;
}
+ } else {
+ percent = 50; /* Default setting */
}
XBell(Tk_Display(Tk_MainWindow(interp)), percent);
return TCL_OK;
--- a/generic/bltConfig.c
+++ b/generic/bltConfig.c
@@ -977,6 +977,7 @@
int dropOffset;
colorPtr = NULL;
+ color2Ptr = NULL;
dropOffset = 0;
if ((string != NULL) && (string[0] != '\0')) {
int nElem;
--- a/generic/bltHtext.c
+++ b/generic/bltHtext.c
@@ -3100,6 +3100,8 @@
forceCopy = 0;
} else {
htPtr->last = htPtr->first - 1;
+ lineNum = htPtr->first;
+ lastY = 0;
}
/* Draw each line */
--- a/generic/bltImage.c
+++ b/generic/bltImage.c
@@ -2738,7 +2738,7 @@
if (opacity2<0.0) {
a1 = (1.0 - a2);
} else {
- a2 = (opacity2<0.0 ? 0.0 : (opacity2>1.0?1.0:opacity2));
+ a1 = (opacity2<0.0 ? 0.0 : (opacity2>1.0?1.0:opacity2));
}
for (endPtr = destPtr + count; destPtr < endPtr; srcPtr++, src2Ptr++, destPtr++) {
--- a/generic/bltTabnotebook.c
+++ b/generic/bltTabnotebook.c
@@ -2430,7 +2430,7 @@
int cavityWidth, cavityHeight;
int width, height;
int dx, dy;
- int x, y;
+ int x = 0, y = 0;
nbPtr = tabPtr->nbPtr;
pad = nbPtr->inset + nbPtr->inset2;
--- a/generic/bltTabset.c
+++ b/generic/bltTabset.c
@@ -5771,14 +5771,6 @@
* side when correcting for left/right slants.
*/
switch (setPtr->side) {
- case SIDE_TOP:
- case SIDE_BOTTOM:
- if (setPtr->slant == SLANT_LEFT) {
- x += setPtr->overlap;
- } else if (setPtr->slant == SLANT_RIGHT) {
- x -= setPtr->overlap;
- }
- break;
case SIDE_LEFT:
case SIDE_RIGHT:
if (setPtr->slant == SLANT_LEFT) {
@@ -5787,6 +5779,15 @@
y -= setPtr->overlap;
}
break;
+ case SIDE_TOP:
+ case SIDE_BOTTOM:
+ default:
+ if (setPtr->slant == SLANT_LEFT) {
+ x += setPtr->overlap;
+ } else if (setPtr->slant == SLANT_RIGHT) {
+ x -= setPtr->overlap;
+ }
+ break;
}
/*
@@ -5817,7 +5818,7 @@
iw = imgWidth = ImageWidth(image);
ih = imgHeight = ImageHeight(image);
}
- img2Width = img2Height = 0;
+ iw2 = ih2 = img2Width = img2Height = 0;
if (image2 != NULL) {
iw2 = img2Width = ImageWidth(image2);
ih2 = img2Height = ImageHeight(image2);
@@ -5847,6 +5848,7 @@
tx = x + (tabPtr->screenWidth - tabPtr->textWidth) / 2;
break;
case SIDE_TOP:
+ default:
tx = x + (tabPtr->screenWidth - tabPtr->textWidth) / 2;
ty = y + dy + tabPtr->iPadY.side1 + IMAGE_PAD;
ix = x + (tabPtr->screenWidth - iw) / 2;
@@ -5915,6 +5917,7 @@
i2x = x + (tabPtr->screenWidth - iw2) / 2;
break;
case SIDE_TOP:
+ default:
i2y = iy + imgHeight + IMAGE_PAD + setPtr->gapLeft;
i2x = x + (tabPtr->screenWidth - iw2) / 2;
break;
--- a/generic/tkButton.c
+++ b/generic/tkButton.c
@@ -1701,7 +1701,7 @@
GC newGC;
unsigned long mask;
Tk_Image image;
- char *oldTextVar, *oldSelVar;
+ char *oldTextVar = NULL, *oldSelVar = NULL;
Blt_Tree oldTree;
int oldNode, result = TCL_OK;
char * oldABdStr = butPtr->activeBdImageString;
@@ -1721,8 +1721,8 @@
if (Blt_ConfigureWidget(interp, butPtr->tkwin, configSpecs,
argc, argv, (char *)butPtr, flags) != TCL_OK) {
- if (oldTextVar) ckfree(oldTextVar);
- if (oldTextVar) ckfree(oldSelVar);
+ if (oldTextVar != NULL) ckfree(oldTextVar);
+ if (oldSelVar != NULL) ckfree(oldSelVar);
return TCL_ERROR;
}
/*
|