Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67c719b

Browse files
Silenced some warnings about comparison between signed and unsigned integer
expressions.
1 parent 2ee44f7 commit 67c719b

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

Modules/_pickle.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ memo_get(PicklerObject *self, PyObject *key)
14561456
pdata[1] = (unsigned char)(*value & 0xff);
14571457
len = 2;
14581458
}
1459-
else if (*value <= 0xffffffffL) {
1459+
else if ((size_t)*value <= 0xffffffffUL) {
14601460
pdata[0] = LONG_BINGET;
14611461
pdata[1] = (unsigned char)(*value & 0xff);
14621462
pdata[2] = (unsigned char)((*value >> 8) & 0xff);
@@ -1513,7 +1513,7 @@ memo_put(PicklerObject *self, PyObject *obj)
15131513
pdata[1] = (unsigned char)idx;
15141514
len = 2;
15151515
}
1516-
else if (idx <= 0xffffffffL) {
1516+
else if ((size_t)idx <= 0xffffffffUL) {
15171517
pdata[0] = LONG_BINPUT;
15181518
pdata[1] = (unsigned char)(idx & 0xff);
15191519
pdata[2] = (unsigned char)((idx >> 8) & 0xff);
@@ -2013,7 +2013,7 @@ save_bytes(PicklerObject *self, PyObject *obj)
20132013
header[1] = (unsigned char)size;
20142014
len = 2;
20152015
}
2016-
else if (size <= 0xffffffffL) {
2016+
else if ((size_t)size <= 0xffffffffUL) {
20172017
header[0] = BINBYTES;
20182018
header[1] = (unsigned char)(size & 0xff);
20192019
header[2] = (unsigned char)((size >> 8) & 0xff);

Parser/node.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ fancy_roundup(int n)
7070
* Note that this would be straightforward if a node stored its current
7171
* capacity. The code is tricky to avoid that.
7272
*/
73-
#define XXXROUNDUP(n) ((n) <= 1 ? (n) : \
74-
(n) <= 128 ? _Py_SIZE_ROUND_UP((n), 4) : \
73+
#define XXXROUNDUP(n) ((n) <= 1 ? (n) : \
74+
(n) <= 128 ? (int)_Py_SIZE_ROUND_UP((n), 4) : \
7575
fancy_roundup(n))
7676

7777

Parser/pgenmain.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ getgrammar(char *filename)
9696
fprintf(stderr, "Parsing error %d, line %d.\n",
9797
err.error, err.lineno);
9898
if (err.text != NULL) {
99-
size_t i;
99+
size_t len;
100+
int i;
100101
fprintf(stderr, "%s", err.text);
101-
i = strlen(err.text);
102-
if (i == 0 || err.text[i-1] != '\n')
102+
len = strlen(err.text);
103+
if (len == 0 || err.text[len-1] != '\n')
103104
fprintf(stderr, "\n");
104105
for (i = 0; i < err.offset; i++) {
105106
if (err.text[i] == '\t')

Parser/printgrammar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void
8484
printdfas(grammar *g, FILE *fp)
8585
{
8686
dfa *d;
87-
int i, j;
87+
int i, j, n;
8888

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

0 commit comments

Comments
 (0)