aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill@shutemov.name>2010-01-20 00:56:11 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-26 14:59:20 -0600
commit31f38120a95980803267fa446f14a864750cdbb5 (patch)
tree0f6e75ddbf84bf1bd6281a80216366d38a8ca324
parent4817d32757cf499a2af375d242ead9394e613882 (diff)
downloadqemu-31f38120a95980803267fa446f14a864750cdbb5.zip
qemu-31f38120a95980803267fa446f14a864750cdbb5.tar.gz
qemu-31f38120a95980803267fa446f14a864750cdbb5.tar.bz2
block/cow.c: fix warnings with _FORTIFY_SOURCE
CC block/cow.o cc1: warnings being treated as errors block/cow.c: In function 'cow_create': block/cow.c:251: error: ignoring return value of 'write', declared with attribute warn_unused_result block/cow.c:253: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result make: *** [block/cow.o] Error 1 Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--block/cow.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/block/cow.c b/block/cow.c
index a70854e..3733385 100644
--- a/block/cow.c
+++ b/block/cow.c
@@ -209,6 +209,7 @@ static int cow_create(const char *filename, QEMUOptionParameter *options)
struct stat st;
int64_t image_sectors = 0;
const char *image_filename = NULL;
+ int ret;
/* Read out options */
while (options && options->name) {
@@ -248,11 +249,23 @@ static int cow_create(const char *filename, QEMUOptionParameter *options)
}
cow_header.sectorsize = cpu_to_be32(512);
cow_header.size = cpu_to_be64(image_sectors * 512);
- write(cow_fd, &cow_header, sizeof(cow_header));
+ ret = qemu_write_full(cow_fd, &cow_header, sizeof(cow_header));
+ if (ret != sizeof(cow_header)) {
+ ret = -1;
+ goto exit;
+ }
+
/* resize to include at least all the bitmap */
- ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3));
+ ret = ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3));
+ if (ret) {
+ ret = -errno;
+ goto exit;
+ }
+
+ ret = 0;
+exit:
close(cow_fd);
- return 0;
+ return ret;
}
static void cow_flush(BlockDriverState *bs)