]> granicus.if.org Git - python/commitdiff
Issue #10310: Use "unsigned int field:1" instead of "signed int field:1" in a
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 17 Jun 2014 21:31:25 +0000 (23:31 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 17 Jun 2014 21:31:25 +0000 (23:31 +0200)
private structure of the _io module to fix a compiler warning (overflow when
assigning the value 1). Fix also a cast in
incrementalnewlinedecoder_setstate().  Patch written by Hallvard B Furuseth.

Modules/_io/textio.c

index 140688fe229dd63ebee520c9065b0a2a118e868d..aed5b2d60685490eadc2e27d6435b54548b077c2 100644 (file)
@@ -224,8 +224,8 @@ typedef struct {
     PyObject_HEAD
     PyObject *decoder;
     PyObject *errors;
-    signed int pendingcr: 1;
-    signed int translate: 1;
+    unsigned int pendingcr: 1;
+    unsigned int translate: 1;
     unsigned int seennl: 3;
 } nldecoder_object;
 
@@ -546,7 +546,7 @@ incrementalnewlinedecoder_setstate(nldecoder_object *self, PyObject *state)
     if (!PyArg_Parse(state, "(OK)", &buffer, &flag))
         return NULL;
 
-    self->pendingcr = (int) flag & 1;
+    self->pendingcr = (int) (flag & 1);
     flag >>= 1;
 
     if (self->decoder != Py_None)