summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-09-05 07:10:23 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-09-05 07:10:23 (GMT)
commit67c719b34b86ba073e6f25cfa3e1994ecb16b888 (patch)
tree7874b80f9e183ee99596bf9a6dfce6dee2489feb
parent2ee44f7f5584b343ee26fb2be46ffde571a5e63d (diff)
downloadcpython-67c719b34b86ba073e6f25cfa3e1994ecb16b888.zip
cpython-67c719b34b86ba073e6f25cfa3e1994ecb16b888.tar.gz
cpython-67c719b34b86ba073e6f25cfa3e1994ecb16b888.tar.bz2
Silenced some warnings about comparison between signed and unsigned integer
expressions.
-rw-r--r--Modules/_pickle.c6
-rw-r--r--Parser/node.c4
-rw-r--r--Parser/pgenmain.c7
-rw-r--r--Parser/printgrammar.c5
4 files changed, 12 insertions, 10 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index ba9ba99..24524a6 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -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);
diff --git a/Parser/node.c b/Parser/node.c
index 564bd91..0010324 100644
--- a/Parser/node.c
+++ b/Parser/node.c
@@ -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))
diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c
index 017a4f9..0f055d6 100644
--- a/Parser/pgenmain.c
+++ b/Parser/pgenmain.c
@@ -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')
diff --git a/Parser/printgrammar.c b/Parser/printgrammar.c
index dd7e6ae..7311e55 100644
--- a/Parser/printgrammar.c
+++ b/Parser/printgrammar.c
@@ -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");
}