Merge pull request #7050 from radarhere/warning

Fixed compilation warnings
This commit is contained in:
mergify[bot] 2023-03-31 12:23:08 +00:00 committed by GitHub
commit b4419169a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View File

@ -502,12 +502,9 @@ getink(PyObject *color, Imaging im, char *ink) {
be cast to either UINT8 or INT32 */ be cast to either UINT8 or INT32 */
int rIsInt = 0; int rIsInt = 0;
int tupleSize; int tupleSize = PyTuple_Check(color) ? PyTuple_GET_SIZE(color) : -1;
if (PyTuple_Check(color)) { if (tupleSize == 1) {
tupleSize = PyTuple_GET_SIZE(color); color = PyTuple_GetItem(color, 0);
if (tupleSize == 1) {
color = PyTuple_GetItem(color, 0);
}
} }
if (im->type == IMAGING_TYPE_UINT8 || im->type == IMAGING_TYPE_INT32 || if (im->type == IMAGING_TYPE_UINT8 || im->type == IMAGING_TYPE_INT32 ||
im->type == IMAGING_TYPE_SPECIAL) { im->type == IMAGING_TYPE_SPECIAL) {
@ -521,7 +518,7 @@ getink(PyObject *color, Imaging im, char *ink) {
PyErr_SetString( PyErr_SetString(
PyExc_TypeError, "color must be int or single-element tuple"); PyExc_TypeError, "color must be int or single-element tuple");
return NULL; return NULL;
} else if (!PyTuple_Check(color)) { } else if (tupleSize == -1) {
PyErr_SetString(PyExc_TypeError, "color must be int or tuple"); PyErr_SetString(PyExc_TypeError, "color must be int or tuple");
return NULL; return NULL;
} }

View File

@ -341,7 +341,10 @@ splitlists(
PixelList *l, *r, *c, *n; PixelList *l, *r, *c, *n;
int i; int i;
int nRight, nLeft; int nRight;
#ifndef NO_OUTPUT
int nLeft;
#endif
int splitColourVal; int splitColourVal;
#ifdef TEST_SPLIT #ifdef TEST_SPLIT
@ -396,12 +399,17 @@ splitlists(
} }
#endif #endif
nCount[0] = nCount[1] = 0; nCount[0] = nCount[1] = 0;
nLeft = nRight = 0; nRight = 0;
#ifndef NO_OUTPUT
nLeft = 0;
#endif
for (left = 0, c = h[axis]; c;) { for (left = 0, c = h[axis]; c;) {
left = left + c->count; left = left + c->count;
nCount[0] += c->count; nCount[0] += c->count;
c->flag = 0; c->flag = 0;
#ifndef NO_OUTPUT
nLeft++; nLeft++;
#endif
c = c->next[axis]; c = c->next[axis];
if (left * 2 > pixelCount) { if (left * 2 > pixelCount) {
break; break;
@ -414,7 +422,9 @@ splitlists(
break; break;
} }
c->flag = 0; c->flag = 0;
#ifndef NO_OUTPUT
nLeft++; nLeft++;
#endif
nCount[0] += c->count; nCount[0] += c->count;
} }
} }
@ -430,7 +440,9 @@ splitlists(
} }
c->flag = 1; c->flag = 1;
nRight++; nRight++;
#ifndef NO_OUTPUT
nLeft--; nLeft--;
#endif
nCount[0] -= c->count; nCount[0] -= c->count;
nCount[1] += c->count; nCount[1] += c->count;
} }