]> granicus.if.org Git - python/commitdiff
unpack_string(): avoid a compiler warning (about a real bug!) by
authorGuido van Rossum <guido@python.org>
Sat, 20 Jul 2002 00:38:01 +0000 (00:38 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 20 Jul 2002 00:38:01 +0000 (00:38 +0000)
copying the result of fgetc() into an int variable before testing it
for EOF.

Modules/_hotshot.c

index 7bd99c84ad442aa6033437186a1c710b7847bb4b..625d1ba1cdc383022c74ae6da885d85c9c263dd1 100644 (file)
@@ -305,6 +305,7 @@ unpack_string(LogReaderObject *self, PyObject **pvalue)
     int i;
     int len;
     int err;
+    int ch;
     char *buf;
     
     if ((err = unpack_packed_int(self, &len, 0)))
@@ -312,7 +313,9 @@ unpack_string(LogReaderObject *self, PyObject **pvalue)
 
     buf = malloc(len);
     for (i=0; i < len; i++) {
-        if ((buf[i] = fgetc(self->logfp)) == EOF) {
+        ch = fgetc(self->logfp);
+       buf[i] = ch;
+        if (ch == EOF) {
             free(buf);
             return ERR_EOF;
         }