aboutsummaryrefslogtreecommitdiff
path: root/extract-gcov.c
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-09-08 15:58:41 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-09-08 15:58:41 +1000
commit7ba8414262c777bb277ef04bf36b11e9b5d8be58 (patch)
tree045b984c17eebb237590a57ca5f6b69c18e6232c /extract-gcov.c
parent67301baebfce31641d117eacf920e87f75c64d4f (diff)
downloadskiboot-7ba8414262c777bb277ef04bf36b11e9b5d8be58.zip
skiboot-7ba8414262c777bb277ef04bf36b11e9b5d8be58.tar.gz
skiboot-7ba8414262c777bb277ef04bf36b11e9b5d8be58.tar.bz2
Fix possible passing of -1 to write() in extract-gcov.c
Just print an error and exit() instead Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'extract-gcov.c')
-rw-r--r--extract-gcov.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/extract-gcov.c b/extract-gcov.c
index 75c1108..c9b82f3 100644
--- a/extract-gcov.c
+++ b/extract-gcov.c
@@ -128,6 +128,11 @@ static void write_gcda(char *addr, struct gcov_info* gi)
printf("Writing %s\n", filename);
fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
+ if (fd < 0) {
+ fprintf(stderr, "Error opening file %s: %d %s\n",
+ filename, errno, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
write_u32(fd, GCOV_DATA_MAGIC);
write_u32(fd, be32toh(gi->version));
write_u32(fd, be32toh(gi->stamp));