qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 01/18] Do not disable _FORTIFY_SOURCE
@ 2009-12-20  1:39 Kirill A. Shutemov
  2009-12-20  1:39 ` [Qemu-devel] [PATCH 02/18] block.c: fix warning with _FORTIFY_SOURCE Kirill A. Shutemov
  2009-12-20 11:38 ` [Qemu-devel] [PATCH 01/18] Do not disable _FORTIFY_SOURCE Blue Swirl
  0 siblings, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

Let's fix code instead!

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 configure |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index d815c7a..17f3d42 100755
--- a/configure
+++ b/configure
@@ -97,7 +97,6 @@ CFLAGS="-g $CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
-QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
 QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
 LDFLAGS="-g $LDFLAGS"
 
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 02/18] block.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39 [Qemu-devel] [PATCH 01/18] Do not disable _FORTIFY_SOURCE Kirill A. Shutemov
@ 2009-12-20  1:39 ` Kirill A. Shutemov
  2009-12-20  1:39   ` [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: " Kirill A. Shutemov
  2009-12-22 18:35   ` [Qemu-devel] [PATCH 02/18] block.c: " Blue Swirl
  2009-12-20 11:38 ` [Qemu-devel] [PATCH 01/18] Do not disable _FORTIFY_SOURCE Blue Swirl
  1 sibling, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    block.o
cc1: warnings being treated as errors
block.c: In function 'bdrv_open2':
block.c:400: error: ignoring return value of 'realpath', declared with attribute warn_unused_result

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 block.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index 3f3496e..30ae2b1 100644
--- a/block.c
+++ b/block.c
@@ -396,8 +396,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
         if (is_protocol)
             snprintf(backing_filename, sizeof(backing_filename),
                      "%s", filename);
-        else
-            realpath(filename, backing_filename);
+        else if (!realpath(filename, backing_filename))
+            return -errno;
 
         bdrv_qcow2 = bdrv_find_format("qcow2");
         options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39 ` [Qemu-devel] [PATCH 02/18] block.c: fix warning with _FORTIFY_SOURCE Kirill A. Shutemov
@ 2009-12-20  1:39   ` Kirill A. Shutemov
  2009-12-20  1:39     ` [Qemu-devel] [PATCH 04/18] block/cow.c: fix warnings " Kirill A. Shutemov
  2009-12-20 23:02     ` [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: " Paul Brook
  2009-12-22 18:35   ` [Qemu-devel] [PATCH 02/18] block.c: " Blue Swirl
  1 sibling, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    posix-aio-compat.o
cc1: warnings being treated as errors
posix-aio-compat.c: In function 'aio_signal_handler':
posix-aio-compat.c:505: error: ignoring return value of 'write', declared with attribute warn_unused_result
make: *** [posix-aio-compat.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 posix-aio-compat.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index dc14f53..555e263 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -502,7 +502,8 @@ static void aio_signal_handler(int signum)
     if (posix_aio_state) {
         char byte = 0;
 
-        write(posix_aio_state->wfd, &byte, sizeof(byte));
+        if (write(posix_aio_state->wfd, &byte, sizeof(byte)) != sizeof(byte))
+            die("write()");
     }
 
     qemu_service_io();
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 04/18] block/cow.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39   ` [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: " Kirill A. Shutemov
@ 2009-12-20  1:39     ` Kirill A. Shutemov
  2009-12-20  1:39       ` [Qemu-devel] [PATCH 05/18] block/qcow.c: " Kirill A. Shutemov
  2009-12-20 23:02     ` [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: " Paul Brook
  1 sibling, 1 reply; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  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>
---
 block/cow.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/block/cow.c b/block/cow.c
index a70854e..1132614 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 = write(cow_fd, &cow_header, sizeof(cow_header));
+    if (ret != sizeof(cow_header)) {
+        ret = -errno;
+        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)
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 05/18] block/qcow.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39     ` [Qemu-devel] [PATCH 04/18] block/cow.c: fix warnings " Kirill A. Shutemov
@ 2009-12-20  1:39       ` Kirill A. Shutemov
  2009-12-20  1:39         ` [Qemu-devel] [PATCH 06/18] block/vmdk.o: " Kirill A. Shutemov
  0 siblings, 1 reply; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    block/qcow.o
cc1: warnings being treated as errors
block/qcow.c: In function 'qcow_create':
block/qcow.c:804: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow.c:806: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow.c:811: error: ignoring return value of 'write', declared with attribute warn_unused_result
make: *** [block/qcow.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 block/qcow.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index 7fc85ae..db5a0e2 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -750,6 +750,7 @@ static int qcow_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) {
@@ -801,17 +802,34 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options)
     }
 
     /* write all the data */
-    write(fd, &header, sizeof(header));
+    ret = write(fd, &header, sizeof(header));
+    if (ret != sizeof(header)) {
+        ret = -errno;
+        goto exit;
+    }
+
     if (backing_file) {
-        write(fd, backing_file, backing_filename_len);
+        ret = write(fd, backing_file, backing_filename_len);
+        if (ret != backing_filename_len) {
+            ret = -errno;
+            goto exit;
+        }
+
     }
     lseek(fd, header_size, SEEK_SET);
     tmp = 0;
     for(i = 0;i < l1_size; i++) {
-        write(fd, &tmp, sizeof(tmp));
+        ret = write(fd, &tmp, sizeof(tmp));
+        if (ret != sizeof(tmp)) {
+            ret = -errno;
+            goto exit;
+        }
     }
+
+    ret = 0;
+exit:
     close(fd);
-    return 0;
+    return ret;
 }
 
 static int qcow_make_empty(BlockDriverState *bs)
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 06/18] block/vmdk.o: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39       ` [Qemu-devel] [PATCH 05/18] block/qcow.c: " Kirill A. Shutemov
@ 2009-12-20  1:39         ` Kirill A. Shutemov
  2009-12-20  1:39           ` [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning " Kirill A. Shutemov
  0 siblings, 1 reply; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  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 <kirill@shutemov.name>
---
 block/vmdk.c |   50 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 4e48622..38e6c62 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 = write(fd, &magic, sizeof(magic));
+    if (ret != sizeof(magic)) {
+        ret = -errno;
+        goto exit;
+    }
+    ret = write(fd, &header, sizeof(header));
+    if (ret != sizeof(header)) {
+        ret = -errno;
+        goto exit;
+    }
 
-    ftruncate(fd, header.grain_offset << 9);
+    ret = ftruncate(fd, header.grain_offset << 9);
+    if (ret < 0) {
+        ret = -errno;
+        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 = write(fd, &tmp, sizeof(tmp));
+        if (ret != sizeof(tmp)) {
+            ret = -errno;
+            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 = write(fd, &tmp, sizeof(tmp));
+        if (ret != sizeof(tmp)) {
+            ret = -errno;
+            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 = write(fd, desc, strlen(desc));
+    if (ret != strlen(desc)) {
+        ret = -errno;
+        goto exit;
+    }
 
+    ret = 0;
+exit:
     close(fd);
-    return 0;
+    return ret;
 }
 
 static void vmdk_close(BlockDriverState *bs)
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39         ` [Qemu-devel] [PATCH 06/18] block/vmdk.o: " Kirill A. Shutemov
@ 2009-12-20  1:39           ` Kirill A. Shutemov
  2009-12-20  1:39             ` [Qemu-devel] [PATCH 08/18] block/vvfat.c: fix warnings " Kirill A. Shutemov
  2009-12-22 21:02             ` [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning " Blue Swirl
  0 siblings, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    block/bochs.o
cc1: warnings being treated as errors
block/bochs.c: In function 'seek_to_sector':
block/bochs.c:202: error: ignoring return value of 'read', declared with attribute warn_unused_result
make: *** [block/bochs.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 block/bochs.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/block/bochs.c b/block/bochs.c
index bac81c4..f6a18f2 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -199,7 +199,8 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
     // read in bitmap for current extent
     lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
 
-    read(s->fd, &bitmap_entry, 1);
+    if (read(s->fd, &bitmap_entry, 1) != 1)
+        return -1;
 
     if (!((bitmap_entry >> (extent_offset % 8)) & 1))
     {
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 08/18] block/vvfat.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39           ` [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning " Kirill A. Shutemov
@ 2009-12-20  1:39             ` Kirill A. Shutemov
  2009-12-20  1:39               ` [Qemu-devel] [PATCH 09/18] block/qcow2.c: " Kirill A. Shutemov
  2009-12-20 10:48               ` [Qemu-devel] [PATCH 08/18] block/vvfat.c: " Kevin Wolf
  2009-12-22 21:02             ` [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning " Blue Swirl
  1 sibling, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    block/vvfat.o
cc1: warnings being treated as errors
block/vvfat.c: In function 'commit_one_file':
block/vvfat.c:2259: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result
make: *** [block/vvfat.o] Error 1
  CC    block/vvfat.o
In file included from /usr/include/stdio.h:912,
                 from ./qemu-common.h:19,
                 from block/vvfat.c:27:
In function 'snprintf',
    inlined from 'init_directories' at block/vvfat.c:871,
    inlined from 'vvfat_open' at block/vvfat.c:1068:
/usr/include/bits/stdio2.h:65: error: call to __builtin___snprintf_chk will always overflow destination buffer
make: *** [block/vvfat.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 block/vvfat.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/vvfat.c b/block/vvfat.c
index 063f731..7b6a405 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -868,7 +868,8 @@ static int init_directories(BDRVVVFATState* s,
     {
 	direntry_t* entry=array_get_next(&(s->directory));
 	entry->attributes=0x28; /* archive | volume label */
-	snprintf((char*)entry->name,11,"QEMU VVFAT");
+	snprintf((char*)entry->name,8,"QEMU VV");
+	snprintf((char*)entry->extension,3,"FAT");
     }
 
     /* Now build FAT, and write back information into directory */
@@ -2256,7 +2257,7 @@ static int commit_one_file(BDRVVVFATState* s,
 	c = c1;
     }
 
-    ftruncate(fd, size);
+    assert(!ftruncate(fd, size));
     close(fd);
 
     return commit_mappings(s, first_cluster, dir_index);
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 09/18] block/qcow2.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39             ` [Qemu-devel] [PATCH 08/18] block/vvfat.c: fix warnings " Kirill A. Shutemov
@ 2009-12-20  1:39               ` Kirill A. Shutemov
  2009-12-20  1:39                 ` [Qemu-devel] [PATCH 10/18] net/slirp.c: fix warning " Kirill A. Shutemov
  2009-12-20  9:08                 ` [Qemu-devel] Re: [PATCH 09/18] block/qcow2.c: fix warnings " Andreas Schwab
  2009-12-20 10:48               ` [Qemu-devel] [PATCH 08/18] block/vvfat.c: " Kevin Wolf
  1 sibling, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    block/qcow2.o
cc1: warnings being treated as errors
block/qcow2.c: In function 'qcow_create2':
block/qcow2.c:829: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:838: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:839: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:841: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:844: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:849: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:852: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:855: error: ignoring return value of 'write', declared with attribute warn_unused_result
make: *** [block/qcow2.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 block/qcow2.c |   54 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 984264b..70287f2 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -743,7 +743,7 @@ static int qcow_create2(const char *filename, int64_t total_size,
     uint64_t tmp, offset;
     QCowCreateState s1, *s = &s1;
     QCowExtension ext_bf = {0, 0};
-
+    int ret;
 
     memset(s, 0, sizeof(*s));
 
@@ -826,7 +826,11 @@ static int qcow_create2(const char *filename, int64_t total_size,
         ref_clusters * s->cluster_size);
 
     /* write all the data */
-    write(fd, &header, sizeof(header));
+    ret = write(fd, &header, sizeof(header));
+    if (ret != sizeof(header)) {
+        ret = -errno;
+        goto exit;
+    }
     if (backing_file) {
         if (backing_format_len) {
             char zero[16];
@@ -835,25 +839,55 @@ static int qcow_create2(const char *filename, int64_t total_size,
             memset(zero, 0, sizeof(zero));
             cpu_to_be32s(&ext_bf.magic);
             cpu_to_be32s(&ext_bf.len);
-            write(fd, &ext_bf, sizeof(ext_bf));
-            write(fd, backing_format, backing_format_len);
+            ret = write(fd, &ext_bf, sizeof(ext_bf));
+            if (ret != sizeof(ext_bf)) {
+                ret = -errno;
+                goto exit;
+            }
+            ret = write(fd, backing_format, backing_format_len);
+            if (ret != backing_format_len) {
+                ret = -errno;
+                goto exit;
+            }
             if (padding > 0) {
-                write(fd, zero, padding);
+                ret = write(fd, zero, padding);
+                if (ret != padding) {
+                    ret = -errno;
+                    goto exit;
+                }
             }
         }
-        write(fd, backing_file, backing_filename_len);
+        ret = write(fd, backing_file, backing_filename_len);
+        if (ret != backing_filename_len) {
+            ret = -errno;
+            goto exit;
+        }
     }
     lseek(fd, s->l1_table_offset, SEEK_SET);
     tmp = 0;
     for(i = 0;i < l1_size; i++) {
-        write(fd, &tmp, sizeof(tmp));
+        ret = write(fd, &tmp, sizeof(tmp));
+        if (ret != sizeof(tmp)) {
+            ret = -errno;
+            goto exit;
+        }
     }
     lseek(fd, s->refcount_table_offset, SEEK_SET);
-    write(fd, s->refcount_table, s->cluster_size);
+    ret = write(fd, s->refcount_table, s->cluster_size);
+    if (ret != s->cluster_size) {
+        ret = -errno;
+        goto exit;
+    }
 
     lseek(fd, s->refcount_block_offset, SEEK_SET);
-    write(fd, s->refcount_block, ref_clusters * s->cluster_size);
+    ret = write(fd, s->refcount_block, ref_clusters * s->cluster_size);
+    if (ret != s->cluster_size) {
+        ret = -errno;
+        goto exit;
+    }
 
+    ret = 0;
+exit:
     qemu_free(s->refcount_table);
     qemu_free(s->refcount_block);
     close(fd);
@@ -867,7 +901,7 @@ static int qcow_create2(const char *filename, int64_t total_size,
         bdrv_close(bs);
     }
 
-    return 0;
+    return ret;
 }
 
 static int qcow_create(const char *filename, QEMUOptionParameter *options)
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 10/18] net/slirp.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39               ` [Qemu-devel] [PATCH 09/18] block/qcow2.c: " Kirill A. Shutemov
@ 2009-12-20  1:39                 ` Kirill A. Shutemov
  2009-12-20  1:39                   ` [Qemu-devel] [PATCH 11/18] usb-linux.c: " Kirill A. Shutemov
  2009-12-22 18:50                   ` [Qemu-devel] [PATCH 10/18] net/slirp.c: " Blue Swirl
  2009-12-20  9:08                 ` [Qemu-devel] Re: [PATCH 09/18] block/qcow2.c: fix warnings " Andreas Schwab
  1 sibling, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    net/slirp.o
cc1: warnings being treated as errors
net/slirp.c: In function 'slirp_smb_cleanup':
net/slirp.c:470: error: ignoring return value of 'system', declared with attribute warn_unused_result
make: *** [net/slirp.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 net/slirp.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index 3f91c4b..1f16814 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -464,10 +464,15 @@ int net_slirp_redir(const char *redir_str)
 static void slirp_smb_cleanup(SlirpState *s)
 {
     char cmd[128];
+    int ret;
 
     if (s->smb_dir[0] != '\0') {
         snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
-        system(cmd);
+        ret = system(cmd);
+        if (ret) {
+            qemu_error("'%s' failed. Error code: %d\n", cmd, ret);
+            /* abort() ? */
+        }
         s->smb_dir[0] = '\0';
     }
 }
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 11/18] usb-linux.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                 ` [Qemu-devel] [PATCH 10/18] net/slirp.c: fix warning " Kirill A. Shutemov
@ 2009-12-20  1:39                   ` Kirill A. Shutemov
  2009-12-20  1:39                     ` [Qemu-devel] [PATCH 12/18] savevm.c: " Kirill A. Shutemov
  2009-12-22 19:03                     ` [Qemu-devel] [PATCH 11/18] usb-linux.c: " Blue Swirl
  2009-12-22 18:50                   ` [Qemu-devel] [PATCH 10/18] net/slirp.c: " Blue Swirl
  1 sibling, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    usb-linux.o
cc1: warnings being treated as errors
usb-linux.c: In function 'usb_host_read_file':
usb-linux.c:1204: error: ignoring return value of 'fgets', declared with attribute warn_unused_result
make: *** [usb-linux.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 usb-linux.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index 88728e9..67bfa7a 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1201,9 +1201,12 @@ static int usb_host_read_file(char *line, size_t line_size, const char *device_f
              device_file);
     f = fopen(filename, "r");
     if (f) {
-        fgets(line, line_size, f);
+        if (fgets(line, line_size, f))
+            ret = 1;
+        else
+            ret = 0;
+
         fclose(f);
-        ret = 1;
 #if 0
     } else {
         if (mon)
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 12/18] savevm.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                   ` [Qemu-devel] [PATCH 11/18] usb-linux.c: " Kirill A. Shutemov
@ 2009-12-20  1:39                     ` Kirill A. Shutemov
  2009-12-20  1:39                       ` [Qemu-devel] [PATCH 13/18] slirp/misc.c: " Kirill A. Shutemov
  2009-12-22 19:21                       ` [Qemu-devel] [PATCH 12/18] savevm.c: " Blue Swirl
  2009-12-22 19:03                     ` [Qemu-devel] [PATCH 11/18] usb-linux.c: " Blue Swirl
  1 sibling, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    savevm.o
cc1: warnings being treated as errors
savevm.c: In function 'file_put_buffer':
savevm.c:342: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
make: *** [savevm.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 savevm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/savevm.c b/savevm.c
index aefe052..829f735 100644
--- a/savevm.c
+++ b/savevm.c
@@ -339,8 +339,7 @@ static int file_put_buffer(void *opaque, const uint8_t *buf,
 {
     QEMUFileStdio *s = opaque;
     fseek(s->stdio_file, pos, SEEK_SET);
-    fwrite(buf, 1, size, s->stdio_file);
-    return size;
+    return fwrite(buf, 1, size, s->stdio_file);
 }
 
 static int file_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 13/18] slirp/misc.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                     ` [Qemu-devel] [PATCH 12/18] savevm.c: " Kirill A. Shutemov
@ 2009-12-20  1:39                       ` Kirill A. Shutemov
  2009-12-20  1:39                         ` [Qemu-devel] [PATCH 14/18] vl.c: " Kirill A. Shutemov
  2009-12-22 19:21                       ` [Qemu-devel] [PATCH 12/18] savevm.c: " Blue Swirl
  1 sibling, 1 reply; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    slirp/misc.o
cc1: warnings being treated as errors
slirp/misc.c: In function 'fork_exec':
slirp/misc.c:209: error: ignoring return value of 'write', declared with attribute warn_unused_result
make: *** [slirp/misc.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 slirp/misc.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index c76ad8f..05f4fb3 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -200,14 +200,8 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
 		execvp(argv[0], (char **)argv);
 
 		/* Ooops, failed, let's tell the user why */
-		  {
-			  char buff[256];
-
-			  snprintf(buff, sizeof(buff),
-                                   "Error: execvp of %s failed: %s\n",
-                                   argv[0], strerror(errno));
-			  write(2, buff, strlen(buff)+1);
-		  }
+        fprintf(stderr, "Error: execvp of %s failed: %s\n",
+                argv[0], strerror(errno));
 		close(0); close(1); close(2); /* XXX */
 		exit(1);
 
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 14/18] vl.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                       ` [Qemu-devel] [PATCH 13/18] slirp/misc.c: " Kirill A. Shutemov
@ 2009-12-20  1:39                         ` Kirill A. Shutemov
  2009-12-20  1:39                           ` [Qemu-devel] [PATCH 15/18] monitor.c: fix warnings " Kirill A. Shutemov
  2009-12-22 21:12                           ` [Qemu-devel] [PATCH 14/18] vl.c: fix warning " Blue Swirl
  0 siblings, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    i386-softmmu/vl.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'qemu_event_increment':
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:3404: error: ignoring return value of 'write', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'main':
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:5774: error: ignoring return value of 'write', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6064: error: ignoring return value of 'chdir', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6083: error: ignoring return value of 'chdir', declared with attribute warn_unused_result
make[1]: *** [vl.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 vl.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/vl.c b/vl.c
index e606903..60a2c5e 100644
--- a/vl.c
+++ b/vl.c
@@ -3383,7 +3383,11 @@ static void qemu_event_increment(void)
     if (io_thread_fd == -1)
         return;
 
-    write(io_thread_fd, &byte, sizeof(byte));
+    if (write(io_thread_fd, &byte, sizeof(byte)) != sizeof(byte)){
+        fprintf(stderr, "qemu_event_increment: write() filed: %s\n",
+                strerror(errno));
+        exit (1);
+    }
 }
 
 static void qemu_event_read(void *opaque)
@@ -5767,7 +5771,8 @@ int main(int argc, char **argv, char **envp)
 #ifndef _WIN32
         if (daemonize) {
             uint8_t status = 1;
-            write(fds[1], &status, 1);
+            if (write(fds[1], &status, 1) != 1)
+                perror("write()");
         } else
 #endif
             fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno));
@@ -6064,7 +6069,8 @@ int main(int argc, char **argv, char **envp)
 	if (len != 1)
 	    exit(1);
 
-	chdir("/");
+	if (chdir("/"))
+        exit(1);
 	TFR(fd = qemu_open("/dev/null", O_RDWR));
 	if (fd == -1)
 	    exit(1);
@@ -6083,7 +6089,8 @@ int main(int argc, char **argv, char **envp)
             fprintf(stderr, "chroot failed\n");
             exit(1);
         }
-        chdir("/");
+        if (chdir("/"))
+            exit(1);
     }
 
     if (run_as) {
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 15/18] monitor.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39                         ` [Qemu-devel] [PATCH 14/18] vl.c: " Kirill A. Shutemov
@ 2009-12-20  1:39                           ` Kirill A. Shutemov
  2009-12-20  1:39                             ` [Qemu-devel] [PATCH 16/18] hw/pc.c: " Kirill A. Shutemov
  2009-12-22 21:12                           ` [Qemu-devel] [PATCH 14/18] vl.c: fix warning " Blue Swirl
  1 sibling, 1 reply; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    i386-softmmu/monitor.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c: In function 'do_memory_save':
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c:1318: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c: In function 'do_physical_memory_save':
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c:1345: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
make[1]: *** [monitor.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 monitor.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/monitor.c b/monitor.c
index c0dc48e..54c7323 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1320,10 +1320,14 @@ static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
         if (l > size)
             l = size;
         cpu_memory_rw_debug(env, addr, buf, l, 0);
-        fwrite(buf, 1, l, f);
+        if (fwrite(buf, 1, l, f) != l) {
+            monitor_printf(mon, "fwrite() failed\n");
+            goto exit;
+        }
         addr += l;
         size -= l;
     }
+exit:
     fclose(f);
 }
 
@@ -1347,11 +1351,15 @@ static void do_physical_memory_save(Monitor *mon, const QDict *qdict,
         if (l > size)
             l = size;
         cpu_physical_memory_rw(addr, buf, l, 0);
-        fwrite(buf, 1, l, f);
+        if (fwrite(buf, 1, l, f) != l) {
+            monitor_printf(mon, "fwrite() failed\n");
+            goto exit;
+        }
         fflush(f);
         addr += l;
         size -= l;
     }
+exit:
     fclose(f);
 }
 
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 16/18] hw/pc.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39                           ` [Qemu-devel] [PATCH 15/18] monitor.c: fix warnings " Kirill A. Shutemov
@ 2009-12-20  1:39                             ` Kirill A. Shutemov
  2009-12-20  1:39                               ` [Qemu-devel] [PATCH 17/18] path.c fix warning " Kirill A. Shutemov
  2009-12-22 20:43                               ` [Qemu-devel] [PATCH 16/18] hw/pc.c: fix warnings " Blue Swirl
  0 siblings, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    i386-softmmu/pc.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c: In function 'load_multiboot':
/usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c:614: error: ignoring return value of 'fread', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c: In function 'load_linux':
/usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c:888: error: ignoring return value of 'fread', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c:889: error: ignoring return value of 'fread', declared with attribute warn_unused_result
make[1]: *** [pc.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 hw/pc.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index db7d58e..83f8dd0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -613,7 +613,10 @@ static int load_multiboot(void *fw_cfg,
 
         mb_kernel_data = qemu_malloc(mb_kernel_size);
         fseek(f, mb_kernel_text_offset, SEEK_SET);
-        fread(mb_kernel_data, 1, mb_kernel_size, f);
+        if (fread(mb_kernel_data, 1, mb_kernel_size, f) != mb_kernel_size) {
+            fprintf(stderr, "fread() failed\n");
+            exit(1);
+        }
         fclose(f);
     }
 
@@ -887,8 +890,14 @@ static void load_linux(void *fw_cfg,
     setup  = qemu_malloc(setup_size);
     kernel = qemu_malloc(kernel_size);
     fseek(f, 0, SEEK_SET);
-    fread(setup, 1, setup_size, f);
-    fread(kernel, 1, kernel_size, f);
+    if (fread(setup, 1, setup_size, f) != setup_size) {
+        fprintf(stderr, "fread() failed\n");
+        exit(1);
+    }
+    if (fread(kernel, 1, kernel_size, f) != kernel_size) {
+        fprintf(stderr, "fread() failed\n");
+        exit(1);
+    }
     fclose(f);
     memcpy(setup, header, MIN(sizeof(header), setup_size));
 
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 17/18] path.c fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                             ` [Qemu-devel] [PATCH 16/18] hw/pc.c: " Kirill A. Shutemov
@ 2009-12-20  1:39                               ` Kirill A. Shutemov
  2009-12-20  1:39                                 ` [Qemu-devel] [PATCH 18/18] linux-user/mmap.c: fix warnings " Kirill A. Shutemov
  2009-12-22 20:49                                 ` [Qemu-devel] [PATCH 17/18] path.c fix warning " Blue Swirl
  2009-12-22 20:43                               ` [Qemu-devel] [PATCH 16/18] hw/pc.c: fix warnings " Blue Swirl
  1 sibling, 2 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    libuser/path.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/path.c: In function 'new_entry':
/usr/src/RPM/BUILD/qemu-0.11.92/path.c:49: error: ignoring return value of 'asprintf', declared with attribute warn_unused_result
make[1]: *** [path.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 path.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/path.c b/path.c
index cc9e007..0d2bf14 100644
--- a/path.c
+++ b/path.c
@@ -46,7 +46,10 @@ static struct pathelem *new_entry(const char *root,
 {
     struct pathelem *new = malloc(sizeof(*new));
     new->name = strdup(name);
-    asprintf(&new->pathname, "%s/%s", root, name);
+    if (asprintf(&new->pathname, "%s/%s", root, name) == -1) {
+        printf("Cannot allocate memory\n");
+        exit(1);
+    }
     new->num_entries = 0;
     return new;
 }
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH 18/18] linux-user/mmap.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39                               ` [Qemu-devel] [PATCH 17/18] path.c fix warning " Kirill A. Shutemov
@ 2009-12-20  1:39                                 ` Kirill A. Shutemov
  2009-12-22 20:49                                 ` [Qemu-devel] [PATCH 17/18] path.c fix warning " Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Kirill A. Shutemov @ 2009-12-20  1:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

  CC    i386-linux-user/mmap.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'mmap_frag':
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:253: error: ignoring return value of 'pread', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'target_mmap':
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:477: error: ignoring return value of 'pread', declared with attribute warn_unused_result
make[1]: *** [mmap.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 linux-user/mmap.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 144fb7c..e496c64 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -250,7 +250,8 @@ static int mmap_frag(abi_ulong real_start,
             mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE);
 
         /* read the corresponding file data */
-        pread(fd, g2h(start), end - start, offset);
+        if (pread(fd, g2h(start), end - start, offset) == -1)
+            return -errno;
 
         /* put final protection */
         if (prot_new != (prot1 | PROT_WRITE))
@@ -474,7 +475,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
                                   -1, 0);
             if (retaddr == -1)
                 goto fail;
-            pread(fd, g2h(start), len, offset);
+            if (pread(fd, g2h(start), len, offset) == -1)
+                return -errno;
             if (!(prot & PROT_WRITE)) {
                 ret = target_mprotect(start, len, prot);
                 if (ret != 0) {
-- 
1.6.5.6

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] Re: [PATCH 09/18] block/qcow2.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39               ` [Qemu-devel] [PATCH 09/18] block/qcow2.c: " Kirill A. Shutemov
  2009-12-20  1:39                 ` [Qemu-devel] [PATCH 10/18] net/slirp.c: fix warning " Kirill A. Shutemov
@ 2009-12-20  9:08                 ` Andreas Schwab
  1 sibling, 0 replies; 30+ messages in thread
From: Andreas Schwab @ 2009-12-20  9:08 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

"Kirill A. Shutemov" <kirill@shutemov.name> writes:

>      lseek(fd, s->refcount_block_offset, SEEK_SET);
> -    write(fd, s->refcount_block, ref_clusters * s->cluster_size);
> +    ret = write(fd, s->refcount_block, ref_clusters * s->cluster_size);
> +    if (ret != s->cluster_size) {
> +        ret = -errno;
> +        goto exit;
> +    }

If you have a short write you'll get an undefined errno.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 08/18] block/vvfat.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39             ` [Qemu-devel] [PATCH 08/18] block/vvfat.c: fix warnings " Kirill A. Shutemov
  2009-12-20  1:39               ` [Qemu-devel] [PATCH 09/18] block/qcow2.c: " Kirill A. Shutemov
@ 2009-12-20 10:48               ` Kevin Wolf
  1 sibling, 0 replies; 30+ messages in thread
From: Kevin Wolf @ 2009-12-20 10:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

Am Sonntag, 20. Dezember 2009 02:39 schrieb Kirill A. Shutemov:
>   CC    block/vvfat.o
> cc1: warnings being treated as errors
> block/vvfat.c: In function 'commit_one_file':
> block/vvfat.c:2259: error: ignoring return value of 'ftruncate', declared 
with attribute warn_unused_result
> make: *** [block/vvfat.o] Error 1
>   CC    block/vvfat.o
> In file included from /usr/include/stdio.h:912,
>                  from ./qemu-common.h:19,
>                  from block/vvfat.c:27:
> In function 'snprintf',
>     inlined from 'init_directories' at block/vvfat.c:871,
>     inlined from 'vvfat_open' at block/vvfat.c:1068:
> /usr/include/bits/stdio2.h:65: error: call to __builtin___snprintf_chk will 
always overflow destination buffer
> make: *** [block/vvfat.o] Error 1
> 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  block/vvfat.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/block/vvfat.c b/block/vvfat.c
> index 063f731..7b6a405 100644
> --- a/block/vvfat.c
> +++ b/block/vvfat.c
> @@ -868,7 +868,8 @@ static int init_directories(BDRVVVFATState* s,
>      {
>  	direntry_t* entry=array_get_next(&(s->directory));
>  	entry->attributes=0x28; /* archive | volume label */
> -	snprintf((char*)entry->name,11,"QEMU VVFAT");
> +	snprintf((char*)entry->name,8,"QEMU VV");
> +	snprintf((char*)entry->extension,3,"FAT");
>      }
>  
>      /* Now build FAT, and write back information into directory */
> @@ -2256,7 +2257,7 @@ static int commit_one_file(BDRVVVFATState* s,
>  	c = c1;
>      }
>  
> -    ftruncate(fd, size);
> +    assert(!ftruncate(fd, size));

Don't use expressions with side effects for assertions. If anyone compiles 
with NDEBUG defined, the ftruncate will be missing.

Kevin

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 01/18] Do not disable _FORTIFY_SOURCE
  2009-12-20  1:39 [Qemu-devel] [PATCH 01/18] Do not disable _FORTIFY_SOURCE Kirill A. Shutemov
  2009-12-20  1:39 ` [Qemu-devel] [PATCH 02/18] block.c: fix warning with _FORTIFY_SOURCE Kirill A. Shutemov
@ 2009-12-20 11:38 ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-20 11:38 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
> Let's fix code instead!

Nice idea. BTW this can't be the first patch in the series, or
bisectability will be broken.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39   ` [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: " Kirill A. Shutemov
  2009-12-20  1:39     ` [Qemu-devel] [PATCH 04/18] block/cow.c: fix warnings " Kirill A. Shutemov
@ 2009-12-20 23:02     ` Paul Brook
  1 sibling, 0 replies; 30+ messages in thread
From: Paul Brook @ 2009-12-20 23:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill A. Shutemov

> --- a/posix-aio-compat.c
> +++ b/posix-aio-compat.c
> @@ -502,7 +502,8 @@ static void aio_signal_handler(int signum)
>      if (posix_aio_state) {
>          char byte = 0;
> 
> -  write(posix_aio_state->wfd, &byte, sizeof(byte));
> +  if (write(posix_aio_state->wfd, &byte, sizeof(byte)) != sizeof(byte))
> +    die("write()");

I'm pretty sure this change is wrong, and shows why you should never blindly 
believe dumb analysis tools.

The write may fail harmlessly if the pipe is already full.

Paul

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 02/18] block.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39 ` [Qemu-devel] [PATCH 02/18] block.c: fix warning with _FORTIFY_SOURCE Kirill A. Shutemov
  2009-12-20  1:39   ` [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: " Kirill A. Shutemov
@ 2009-12-22 18:35   ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-22 18:35 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    block.o
> cc1: warnings being treated as errors
> block.c: In function 'bdrv_open2':
> block.c:400: error: ignoring return value of 'realpath', declared with attribute warn_unused_result
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  block.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block.c b/block.c
> index 3f3496e..30ae2b1 100644
> --- a/block.c
> +++ b/block.c
> @@ -396,8 +396,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
>         if (is_protocol)
>             snprintf(backing_filename, sizeof(backing_filename),
>                      "%s", filename);
> -        else
> -            realpath(filename, backing_filename);
> +        else if (!realpath(filename, backing_filename))
> +            return -errno;
>
>         bdrv_qcow2 = bdrv_find_format("qcow2");
>         options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);

This patch appears to be correct considering:
- return value of realpath
- errno codes in the error case (as advertised by Linux man page and
the functions referenced by OpenBSD man page: lstat(), readlink(2) and
getcwd())
- return value of bdrv_open2().

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 10/18] net/slirp.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                 ` [Qemu-devel] [PATCH 10/18] net/slirp.c: fix warning " Kirill A. Shutemov
  2009-12-20  1:39                   ` [Qemu-devel] [PATCH 11/18] usb-linux.c: " Kirill A. Shutemov
@ 2009-12-22 18:50                   ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-22 18:50 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    net/slirp.o
> cc1: warnings being treated as errors
> net/slirp.c: In function 'slirp_smb_cleanup':
> net/slirp.c:470: error: ignoring return value of 'system', declared with attribute warn_unused_result
> make: *** [net/slirp.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  net/slirp.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/net/slirp.c b/net/slirp.c
> index 3f91c4b..1f16814 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -464,10 +464,15 @@ int net_slirp_redir(const char *redir_str)
>  static void slirp_smb_cleanup(SlirpState *s)
>  {
>     char cmd[128];
> +    int ret;
>
>     if (s->smb_dir[0] != '\0') {
>         snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
> -        system(cmd);
> +        ret = system(cmd);
> +        if (ret) {
> +            qemu_error("'%s' failed. Error code: %d\n", cmd, ret);
> +            /* abort() ? */

This is not correct.

- system() returns -1 on error and the command exit status otherwise,
which may also be nonzero.
- the exit status should be retrieved with WEXITSTATUS() macro, or in
case of error via errno.
- in no case abort() is warranted for smb cleanup.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 11/18] usb-linux.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                   ` [Qemu-devel] [PATCH 11/18] usb-linux.c: " Kirill A. Shutemov
  2009-12-20  1:39                     ` [Qemu-devel] [PATCH 12/18] savevm.c: " Kirill A. Shutemov
@ 2009-12-22 19:03                     ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-22 19:03 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    usb-linux.o
> cc1: warnings being treated as errors
> usb-linux.c: In function 'usb_host_read_file':
> usb-linux.c:1204: error: ignoring return value of 'fgets', declared with attribute warn_unused_result
> make: *** [usb-linux.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  usb-linux.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/usb-linux.c b/usb-linux.c
> index 88728e9..67bfa7a 100644
> --- a/usb-linux.c
> +++ b/usb-linux.c
> @@ -1201,9 +1201,12 @@ static int usb_host_read_file(char *line, size_t line_size, const char *device_f
>              device_file);
>     f = fopen(filename, "r");
>     if (f) {
> -        fgets(line, line_size, f);
> +        if (fgets(line, line_size, f))
> +            ret = 1;
> +        else
> +            ret = 0;
> +
>         fclose(f);
> -        ret = 1;

Considering the return values of fgets() and usb_host_read_file(),
this patch looks OK except for the CODING_STYLE violation.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 12/18] savevm.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                     ` [Qemu-devel] [PATCH 12/18] savevm.c: " Kirill A. Shutemov
  2009-12-20  1:39                       ` [Qemu-devel] [PATCH 13/18] slirp/misc.c: " Kirill A. Shutemov
@ 2009-12-22 19:21                       ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-22 19:21 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    savevm.o
> cc1: warnings being treated as errors
> savevm.c: In function 'file_put_buffer':
> savevm.c:342: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
> make: *** [savevm.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  savevm.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/savevm.c b/savevm.c
> index aefe052..829f735 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -339,8 +339,7 @@ static int file_put_buffer(void *opaque, const uint8_t *buf,
>  {
>     QEMUFileStdio *s = opaque;
>     fseek(s->stdio_file, pos, SEEK_SET);
> -    fwrite(buf, 1, size, s->stdio_file);
> -    return size;
> +    return fwrite(buf, 1, size, s->stdio_file);

Looks OK.

The callers do not handle partial writes, but that's because the
return value is not used correctly. They should be fixed some time.

We are truncating size_t to int, but that is OK given that the input
size is also int. The interfaces should be cleaned up to use
size_t/ssize_t later.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 16/18] hw/pc.c: fix warnings with _FORTIFY_SOURCE
  2009-12-20  1:39                             ` [Qemu-devel] [PATCH 16/18] hw/pc.c: " Kirill A. Shutemov
  2009-12-20  1:39                               ` [Qemu-devel] [PATCH 17/18] path.c fix warning " Kirill A. Shutemov
@ 2009-12-22 20:43                               ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-22 20:43 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    i386-softmmu/pc.o
> cc1: warnings being treated as errors
> /usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c: In function 'load_multiboot':
> /usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c:614: error: ignoring return value of 'fread', declared with attribute warn_unused_result
> /usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c: In function 'load_linux':
> /usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c:888: error: ignoring return value of 'fread', declared with attribute warn_unused_result
> /usr/src/RPM/BUILD/qemu-0.11.92/hw/pc.c:889: error: ignoring return value of 'fread', declared with attribute warn_unused_result
> make[1]: *** [pc.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  hw/pc.c |   15 ++++++++++++---
>  1 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/hw/pc.c b/hw/pc.c
> index db7d58e..83f8dd0 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -613,7 +613,10 @@ static int load_multiboot(void *fw_cfg,
>
>         mb_kernel_data = qemu_malloc(mb_kernel_size);
>         fseek(f, mb_kernel_text_offset, SEEK_SET);
> -        fread(mb_kernel_data, 1, mb_kernel_size, f);
> +        if (fread(mb_kernel_data, 1, mb_kernel_size, f) != mb_kernel_size) {
> +            fprintf(stderr, "fread() failed\n");
> +            exit(1);
> +        }
>         fclose(f);
>     }
>
> @@ -887,8 +890,14 @@ static void load_linux(void *fw_cfg,
>     setup  = qemu_malloc(setup_size);
>     kernel = qemu_malloc(kernel_size);
>     fseek(f, 0, SEEK_SET);
> -    fread(setup, 1, setup_size, f);
> -    fread(kernel, 1, kernel_size, f);
> +    if (fread(setup, 1, setup_size, f) != setup_size) {
> +        fprintf(stderr, "fread() failed\n");
> +        exit(1);
> +    }
> +    if (fread(kernel, 1, kernel_size, f) != kernel_size) {
> +        fprintf(stderr, "fread() failed\n");
> +        exit(1);
> +    }
>     fclose(f);
>     memcpy(setup, header, MIN(sizeof(header), setup_size));

Looks fine to me. If we can't read the kernel, PEBCAK.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 17/18] path.c fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                               ` [Qemu-devel] [PATCH 17/18] path.c fix warning " Kirill A. Shutemov
  2009-12-20  1:39                                 ` [Qemu-devel] [PATCH 18/18] linux-user/mmap.c: fix warnings " Kirill A. Shutemov
@ 2009-12-22 20:49                                 ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-22 20:49 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    libuser/path.o
> cc1: warnings being treated as errors
> /usr/src/RPM/BUILD/qemu-0.11.92/path.c: In function 'new_entry':
> /usr/src/RPM/BUILD/qemu-0.11.92/path.c:49: error: ignoring return value of 'asprintf', declared with attribute warn_unused_result
> make[1]: *** [path.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  path.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/path.c b/path.c
> index cc9e007..0d2bf14 100644
> --- a/path.c
> +++ b/path.c
> @@ -46,7 +46,10 @@ static struct pathelem *new_entry(const char *root,
>  {
>     struct pathelem *new = malloc(sizeof(*new));
>     new->name = strdup(name);
> -    asprintf(&new->pathname, "%s/%s", root, name);
> +    if (asprintf(&new->pathname, "%s/%s", root, name) == -1) {
> +        printf("Cannot allocate memory\n");
> +        exit(1);
> +    }
>     new->num_entries = 0;
>     return new;
>  }

Looks OK.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39           ` [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning " Kirill A. Shutemov
  2009-12-20  1:39             ` [Qemu-devel] [PATCH 08/18] block/vvfat.c: fix warnings " Kirill A. Shutemov
@ 2009-12-22 21:02             ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-22 21:02 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    block/bochs.o
> cc1: warnings being treated as errors
> block/bochs.c: In function 'seek_to_sector':
> block/bochs.c:202: error: ignoring return value of 'read', declared with attribute warn_unused_result
> make: *** [block/bochs.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  block/bochs.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/block/bochs.c b/block/bochs.c
> index bac81c4..f6a18f2 100644
> --- a/block/bochs.c
> +++ b/block/bochs.c
> @@ -199,7 +199,8 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
>     // read in bitmap for current extent
>     lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
>
> -    read(s->fd, &bitmap_entry, 1);
> +    if (read(s->fd, &bitmap_entry, 1) != 1)
> +        return -1;

I think a short read can't happen with 1 bytes, so this looks fine.

Though error checking is incomplete unless it is extended to lseek() calls too.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH 14/18] vl.c: fix warning with _FORTIFY_SOURCE
  2009-12-20  1:39                         ` [Qemu-devel] [PATCH 14/18] vl.c: " Kirill A. Shutemov
  2009-12-20  1:39                           ` [Qemu-devel] [PATCH 15/18] monitor.c: fix warnings " Kirill A. Shutemov
@ 2009-12-22 21:12                           ` Blue Swirl
  1 sibling, 0 replies; 30+ messages in thread
From: Blue Swirl @ 2009-12-22 21:12 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: qemu-devel

On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    i386-softmmu/vl.o
> cc1: warnings being treated as errors
> /usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'qemu_event_increment':
> /usr/src/RPM/BUILD/qemu-0.11.92/vl.c:3404: error: ignoring return value of 'write', declared with attribute warn_unused_result
> /usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'main':
> /usr/src/RPM/BUILD/qemu-0.11.92/vl.c:5774: error: ignoring return value of 'write', declared with attribute warn_unused_result
> /usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6064: error: ignoring return value of 'chdir', declared with attribute warn_unused_result
> /usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6083: error: ignoring return value of 'chdir', declared with attribute warn_unused_result
> make[1]: *** [vl.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  vl.c |   15 +++++++++++----
>  1 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index e606903..60a2c5e 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3383,7 +3383,11 @@ static void qemu_event_increment(void)
>     if (io_thread_fd == -1)
>         return;
>
> -    write(io_thread_fd, &byte, sizeof(byte));
> +    if (write(io_thread_fd, &byte, sizeof(byte)) != sizeof(byte)){
> +        fprintf(stderr, "qemu_event_increment: write() filed: %s\n",
> +                strerror(errno));
> +        exit (1);
> +    }
>  }
>
>  static void qemu_event_read(void *opaque)
> @@ -5767,7 +5771,8 @@ int main(int argc, char **argv, char **envp)
>  #ifndef _WIN32
>         if (daemonize) {
>             uint8_t status = 1;
> -            write(fds[1], &status, 1);
> +            if (write(fds[1], &status, 1) != 1)
> +                perror("write()");
>         } else
>  #endif
>             fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno));
> @@ -6064,7 +6069,8 @@ int main(int argc, char **argv, char **envp)
>        if (len != 1)
>            exit(1);
>
> -       chdir("/");
> +       if (chdir("/"))
> +        exit(1);
>        TFR(fd = qemu_open("/dev/null", O_RDWR));
>        if (fd == -1)
>            exit(1);
> @@ -6083,7 +6089,8 @@ int main(int argc, char **argv, char **envp)
>             fprintf(stderr, "chroot failed\n");
>             exit(1);
>         }
> -        chdir("/");
> +        if (chdir("/"))
> +            exit(1);

Can't comment much on write() parts. chdir() checks are OK, except an
error message would be in order.

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2009-12-22 21:12 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-20  1:39 [Qemu-devel] [PATCH 01/18] Do not disable _FORTIFY_SOURCE Kirill A. Shutemov
2009-12-20  1:39 ` [Qemu-devel] [PATCH 02/18] block.c: fix warning with _FORTIFY_SOURCE Kirill A. Shutemov
2009-12-20  1:39   ` [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: " Kirill A. Shutemov
2009-12-20  1:39     ` [Qemu-devel] [PATCH 04/18] block/cow.c: fix warnings " Kirill A. Shutemov
2009-12-20  1:39       ` [Qemu-devel] [PATCH 05/18] block/qcow.c: " Kirill A. Shutemov
2009-12-20  1:39         ` [Qemu-devel] [PATCH 06/18] block/vmdk.o: " Kirill A. Shutemov
2009-12-20  1:39           ` [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning " Kirill A. Shutemov
2009-12-20  1:39             ` [Qemu-devel] [PATCH 08/18] block/vvfat.c: fix warnings " Kirill A. Shutemov
2009-12-20  1:39               ` [Qemu-devel] [PATCH 09/18] block/qcow2.c: " Kirill A. Shutemov
2009-12-20  1:39                 ` [Qemu-devel] [PATCH 10/18] net/slirp.c: fix warning " Kirill A. Shutemov
2009-12-20  1:39                   ` [Qemu-devel] [PATCH 11/18] usb-linux.c: " Kirill A. Shutemov
2009-12-20  1:39                     ` [Qemu-devel] [PATCH 12/18] savevm.c: " Kirill A. Shutemov
2009-12-20  1:39                       ` [Qemu-devel] [PATCH 13/18] slirp/misc.c: " Kirill A. Shutemov
2009-12-20  1:39                         ` [Qemu-devel] [PATCH 14/18] vl.c: " Kirill A. Shutemov
2009-12-20  1:39                           ` [Qemu-devel] [PATCH 15/18] monitor.c: fix warnings " Kirill A. Shutemov
2009-12-20  1:39                             ` [Qemu-devel] [PATCH 16/18] hw/pc.c: " Kirill A. Shutemov
2009-12-20  1:39                               ` [Qemu-devel] [PATCH 17/18] path.c fix warning " Kirill A. Shutemov
2009-12-20  1:39                                 ` [Qemu-devel] [PATCH 18/18] linux-user/mmap.c: fix warnings " Kirill A. Shutemov
2009-12-22 20:49                                 ` [Qemu-devel] [PATCH 17/18] path.c fix warning " Blue Swirl
2009-12-22 20:43                               ` [Qemu-devel] [PATCH 16/18] hw/pc.c: fix warnings " Blue Swirl
2009-12-22 21:12                           ` [Qemu-devel] [PATCH 14/18] vl.c: fix warning " Blue Swirl
2009-12-22 19:21                       ` [Qemu-devel] [PATCH 12/18] savevm.c: " Blue Swirl
2009-12-22 19:03                     ` [Qemu-devel] [PATCH 11/18] usb-linux.c: " Blue Swirl
2009-12-22 18:50                   ` [Qemu-devel] [PATCH 10/18] net/slirp.c: " Blue Swirl
2009-12-20  9:08                 ` [Qemu-devel] Re: [PATCH 09/18] block/qcow2.c: fix warnings " Andreas Schwab
2009-12-20 10:48               ` [Qemu-devel] [PATCH 08/18] block/vvfat.c: " Kevin Wolf
2009-12-22 21:02             ` [Qemu-devel] [PATCH 07/18] block/bochs.c: fix warning " Blue Swirl
2009-12-20 23:02     ` [Qemu-devel] [PATCH 03/18] posix-aio-compat.c: " Paul Brook
2009-12-22 18:35   ` [Qemu-devel] [PATCH 02/18] block.c: " Blue Swirl
2009-12-20 11:38 ` [Qemu-devel] [PATCH 01/18] Do not disable _FORTIFY_SOURCE Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).