Skip to content

Commit

Permalink
Merge pull request #7050 from radarhere/warning
Browse files Browse the repository at this point in the history
Fixed compilation warnings
  • Loading branch information
mergify[bot] authored Mar 31, 2023
2 parents 93afedf + 89d2cdf commit b441916
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,9 @@ getink(PyObject *color, Imaging im, char *ink) {
be cast to either UINT8 or INT32 */

int rIsInt = 0;
int tupleSize;
if (PyTuple_Check(color)) {
tupleSize = PyTuple_GET_SIZE(color);
if (tupleSize == 1) {
color = PyTuple_GetItem(color, 0);
}
int tupleSize = PyTuple_Check(color) ? PyTuple_GET_SIZE(color) : -1;
if (tupleSize == 1) {
color = PyTuple_GetItem(color, 0);
}
if (im->type == IMAGING_TYPE_UINT8 || im->type == IMAGING_TYPE_INT32 ||
im->type == IMAGING_TYPE_SPECIAL) {
Expand All @@ -521,7 +518,7 @@ getink(PyObject *color, Imaging im, char *ink) {
PyErr_SetString(
PyExc_TypeError, "color must be int or single-element tuple");
return NULL;
} else if (!PyTuple_Check(color)) {
} else if (tupleSize == -1) {
PyErr_SetString(PyExc_TypeError, "color must be int or tuple");
return NULL;
}
Expand Down
16 changes: 14 additions & 2 deletions src/libImaging/Quant.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ splitlists(

PixelList *l, *r, *c, *n;
int i;
int nRight, nLeft;
int nRight;
#ifndef NO_OUTPUT
int nLeft;
#endif
int splitColourVal;

#ifdef TEST_SPLIT
Expand Down Expand Up @@ -396,12 +399,17 @@ splitlists(
}
#endif
nCount[0] = nCount[1] = 0;
nLeft = nRight = 0;
nRight = 0;
#ifndef NO_OUTPUT
nLeft = 0;
#endif
for (left = 0, c = h[axis]; c;) {
left = left + c->count;
nCount[0] += c->count;
c->flag = 0;
#ifndef NO_OUTPUT
nLeft++;
#endif
c = c->next[axis];
if (left * 2 > pixelCount) {
break;
Expand All @@ -414,7 +422,9 @@ splitlists(
break;
}
c->flag = 0;
#ifndef NO_OUTPUT
nLeft++;
#endif
nCount[0] += c->count;
}
}
Expand All @@ -430,7 +440,9 @@ splitlists(
}
c->flag = 1;
nRight++;
#ifndef NO_OUTPUT
nLeft--;
#endif
nCount[0] -= c->count;
nCount[1] += c->count;
}
Expand Down

0 comments on commit b441916

Please sign in to comment.