[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/17] block/vmdk.o: fix warnings with _FORTIFY_SOUR
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 06/17] block/vmdk.o: fix warnings with _FORTIFY_SOURCE |
Date: |
Wed, 20 Jan 2010 00:56:13 +0100 |
From: Kirill A. Shutemov <address@hidden>
CC block/vmdk.o
cc1: warnings being treated as errors
block/vmdk.c: In function 'vmdk_snapshot_create':
block/vmdk.c:236: error: ignoring return value of 'ftruncate', declared with
attribute warn_unused_result
block/vmdk.c: In function 'vmdk_create':
block/vmdk.c:775: error: ignoring return value of 'write', declared with
attribute warn_unused_result
block/vmdk.c:776: error: ignoring return value of 'write', declared with
attribute warn_unused_result
block/vmdk.c:778: error: ignoring return value of 'ftruncate', declared with
attribute warn_unused_result
block/vmdk.c:784: error: ignoring return value of 'write', declared with
attribute warn_unused_result
block/vmdk.c:790: error: ignoring return value of 'write', declared with
attribute warn_unused_result
block/vmdk.c:807: error: ignoring return value of 'write', declared with
attribute warn_unused_result
make: *** [block/vmdk.o] Error 1
Signed-off-by: Kirill A. Shutemov <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
block/vmdk.c | 50 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 4e48622..18c691a 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -233,7 +233,8 @@ static int vmdk_snapshot_create(const char *filename, const
char *backing_file)
memset(&header, 0, sizeof(header));
memcpy(&header,&hdr[4], sizeof(header)); // skip the VMDK4_MAGIC
- ftruncate(snp_fd, header.grain_offset << 9);
+ if (ftruncate(snp_fd, header.grain_offset << 9))
+ goto fail;
/* the descriptor offset = 0x200 */
if (lseek(p_fd, 0x200, SEEK_SET) == -1)
goto fail;
@@ -716,6 +717,7 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options)
int64_t total_size = 0;
const char *backing_file = NULL;
int flags = 0;
+ int ret;
// Read out options
while (options && options->name) {
@@ -772,22 +774,44 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options)
header.check_bytes[3] = 0xa;
/* write all the data */
- write(fd, &magic, sizeof(magic));
- write(fd, &header, sizeof(header));
+ ret = qemu_write_full(fd, &magic, sizeof(magic));
+ if (ret != sizeof(magic)) {
+ ret = -1;
+ goto exit;
+ }
+ ret = qemu_write_full(fd, &header, sizeof(header));
+ if (ret != sizeof(header)) {
+ ret = -1;
+ goto exit;
+ }
- ftruncate(fd, header.grain_offset << 9);
+ ret = ftruncate(fd, header.grain_offset << 9);
+ if (ret < 0) {
+ ret = -1;
+ goto exit;
+ }
/* write grain directory */
lseek(fd, le64_to_cpu(header.rgd_offset) << 9, SEEK_SET);
for (i = 0, tmp = header.rgd_offset + gd_size;
- i < gt_count; i++, tmp += gt_size)
- write(fd, &tmp, sizeof(tmp));
+ i < gt_count; i++, tmp += gt_size) {
+ ret = qemu_write_full(fd, &tmp, sizeof(tmp));
+ if (ret != sizeof(tmp)) {
+ ret = -1;
+ goto exit;
+ }
+ }
/* write backup grain directory */
lseek(fd, le64_to_cpu(header.gd_offset) << 9, SEEK_SET);
for (i = 0, tmp = header.gd_offset + gd_size;
- i < gt_count; i++, tmp += gt_size)
- write(fd, &tmp, sizeof(tmp));
+ i < gt_count; i++, tmp += gt_size) {
+ ret = qemu_write_full(fd, &tmp, sizeof(tmp));
+ if (ret != sizeof(tmp)) {
+ ret = -1;
+ goto exit;
+ }
+ }
/* compose the descriptor */
real_filename = filename;
@@ -804,10 +828,16 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options)
/* write the descriptor */
lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);
- write(fd, desc, strlen(desc));
+ ret = qemu_write_full(fd, desc, strlen(desc));
+ if (ret != strlen(desc)) {
+ ret = -1;
+ goto exit;
+ }
+ ret = 0;
+exit:
close(fd);
- return 0;
+ return ret;
}
static void vmdk_close(BlockDriverState *bs)
--
1.6.5.2
- [Qemu-devel] [PATCH 00/17] Fix compilation with _FORTIFY_SOURCE, Juan Quintela, 2010/01/19
- [Qemu-devel] [PATCH 01/17] Introduce qemu_write_full(), Juan Quintela, 2010/01/19
- [Qemu-devel] [PATCH 02/17] force to test result for qemu_write_full(), Juan Quintela, 2010/01/19
- [Qemu-devel] [PATCH 03/17] posix-aio-compat.c: fix warning with _FORTIFY_SOURCE, Juan Quintela, 2010/01/19
- [Qemu-devel] [PATCH 04/17] block/cow.c: fix warnings with _FORTIFY_SOURCE, Juan Quintela, 2010/01/19
- [Qemu-devel] [PATCH 05/17] block/qcow.c: fix warnings with _FORTIFY_SOURCE, Juan Quintela, 2010/01/19
- [Qemu-devel] [PATCH 06/17] block/vmdk.o: fix warnings with _FORTIFY_SOURCE,
Juan Quintela <=
- [Qemu-devel] [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Juan Quintela, 2010/01/19
- [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Kirill A. Shutemov, 2010/01/20
- Re: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Daniel P. Berrange, 2010/01/20
- Re: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Kirill A. Shutemov, 2010/01/20
- Re: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Kevin Wolf, 2010/01/20
- Re: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Markus Armbruster, 2010/01/20
- Re: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Kirill A. Shutemov, 2010/01/20
- Re: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Markus Armbruster, 2010/01/20
- Re: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Gleb Natapov, 2010/01/20
- Re: [Qemu-devel] Re: [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE, Kirill A. Shutemov, 2010/01/20