* srconv.c (checksum, wr_tr, wr_cs): Likewise.
* sysdump.c (fillup): Return zero on getc or fread EOF. Return count
read.
+2007-10-15 Alan Modra <amodra@bigpond.net.au>
+
+ * objdump.c (print_line): Check fwrite return value.
+ * srconv.c (checksum, wr_tr, wr_cs): Likewise.
+ * sysdump.c (fillup): Return zero on getc or fread EOF. Return count
+ read.
+
2007-10-10 Jim Blandy <jimb@codesourcery.com>
* dwarf.c (process_debug_info): Line up section offsets of
print_line (struct print_file_list *p, unsigned int line)
{
const char *l;
+ size_t len;
--line;
if (line >= p->maxline)
return;
l = p->linemap [line];
- fwrite (l, 1, strcspn (l, "\n\r"), stdout);
- putchar ('\n');
-}
+ /* Test fwrite return value to quiet glibc warning. */
+ len = strcspn (l, "\n\r");
+ if (len == 0 || fwrite (l, len, 1, stdout) == 1)
+ putchar ('\n');
+}
/* Print a range of source code lines. */
/* Glue on a checksum too. */
ptr[bytes] = ~sum;
- fwrite (ptr, bytes + 1, 1, file);
+ if (fwrite (ptr, bytes + 1, 1, file) != 1)
+ /* FIXME: Return error status. */
+ abort ();
}
0x03, /* RL */
0xfd, /* CS */
};
- fwrite (b, 1, sizeof (b), file);
+
+ if (fwrite (b, sizeof (b), 1, file) != 1)
+ /* FIXME: Return error status. */
+ abort ();
}
static void
0x00, /* dot */
0xDE /* CS */
};
- fwrite (b, 1, sizeof (b), file);
+
+ if (fwrite (b, sizeof (b), 1, file) != 1)
+ /* FIXME: Return error status. */
+ abort ();
}
/* Write out the SC records for a unit. Create an SC
int sum;
int i;
- size = getc (file) - 2;
- fread (ptr, 1, size, file);
+ size = getc (file);
+ if (size == EOF
+ || size <= 2)
+ return 0;
+
+ size -= 2;
+ if (fread (ptr, size, 1, file) != 1)
+ return 0;
+
sum = code + size + 2;
for (i = 0; i < size; i++)
if (dump)
dh (ptr, size);
- return size - 1;
+ return size;
}
static barray