Silenced some warnings about comparison between signed and unsigned integer

expressions.
This commit is contained in:
Serhiy Storchaka 2014-09-05 10:10:23 +03:00
parent 2ee44f7f55
commit 67c719b34b
4 changed files with 12 additions and 10 deletions

View File

@ -1456,7 +1456,7 @@ memo_get(PicklerObject *self, PyObject *key)
pdata[1] = (unsigned char)(*value & 0xff);
len = 2;
}
else if (*value <= 0xffffffffL) {
else if ((size_t)*value <= 0xffffffffUL) {
pdata[0] = LONG_BINGET;
pdata[1] = (unsigned char)(*value & 0xff);
pdata[2] = (unsigned char)((*value >> 8) & 0xff);
@ -1513,7 +1513,7 @@ memo_put(PicklerObject *self, PyObject *obj)
pdata[1] = (unsigned char)idx;
len = 2;
}
else if (idx <= 0xffffffffL) {
else if ((size_t)idx <= 0xffffffffUL) {
pdata[0] = LONG_BINPUT;
pdata[1] = (unsigned char)(idx & 0xff);
pdata[2] = (unsigned char)((idx >> 8) & 0xff);
@ -2013,7 +2013,7 @@ save_bytes(PicklerObject *self, PyObject *obj)
header[1] = (unsigned char)size;
len = 2;
}
else if (size <= 0xffffffffL) {
else if ((size_t)size <= 0xffffffffUL) {
header[0] = BINBYTES;
header[1] = (unsigned char)(size & 0xff);
header[2] = (unsigned char)((size >> 8) & 0xff);

View File

@ -70,8 +70,8 @@ fancy_roundup(int n)
* Note that this would be straightforward if a node stored its current
* capacity. The code is tricky to avoid that.
*/
#define XXXROUNDUP(n) ((n) <= 1 ? (n) : \
(n) <= 128 ? _Py_SIZE_ROUND_UP((n), 4) : \
#define XXXROUNDUP(n) ((n) <= 1 ? (n) : \
(n) <= 128 ? (int)_Py_SIZE_ROUND_UP((n), 4) : \
fancy_roundup(n))

View File

@ -96,10 +96,11 @@ getgrammar(char *filename)
fprintf(stderr, "Parsing error %d, line %d.\n",
err.error, err.lineno);
if (err.text != NULL) {
size_t i;
size_t len;
int i;
fprintf(stderr, "%s", err.text);
i = strlen(err.text);
if (i == 0 || err.text[i-1] != '\n')
len = strlen(err.text);
if (len == 0 || err.text[len-1] != '\n')
fprintf(stderr, "\n");
for (i = 0; i < err.offset; i++) {
if (err.text[i] == '\t')

View File

@ -84,7 +84,7 @@ static void
printdfas(grammar *g, FILE *fp)
{
dfa *d;
int i, j;
int i, j, n;
printstates(g, fp);
fprintf(fp, "static dfa dfas[%d] = {\n", g->g_ndfas);
@ -93,7 +93,8 @@ printdfas(grammar *g, FILE *fp)
fprintf(fp, " {%d, \"%s\", %d, %d, states_%d,\n",
d->d_type, d->d_name, d->d_initial, d->d_nstates, i);
fprintf(fp, " \"");
for (j = 0; j < NBYTES(g->g_ll.ll_nlabels); j++)
n = NBYTES(g->g_ll.ll_nlabels);
for (j = 0; j < n; j++)
fprintf(fp, "\\%03o", d->d_first[j] & 0xff);
fprintf(fp, "\"},\n");
}