All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Jean-Christophe Dubois <jcd@tribudubois.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4] avoid compilation warning/errors on up to date
Date: Wed, 17 Jun 2009 16:54:56 -0500	[thread overview]
Message-ID: <4A396630.20105@codemonkey.ws> (raw)
In-Reply-To: <200906172322.35496.jcd@tribudubois.net>

Jean-Christophe Dubois wrote:
> Some system calls are now requiring to have their return value checked.
>
> Without this a warning is emitted and in the case a qemu an error is
> triggered as qemu is considering warnings as errors.
>
> For example:
>
> 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
>
> This is an attempt at removing all these warnings to allow a clean
> compilation with up to date compilers/distributions.
>
> The second version fixes an error detected by Stuart Brady as well
> as some coding style issues. Note however that some of the
> modified files don't follow the qemu coding style (using tabs
> instead of spaces).
>
> The Third version add one ftruncate() system call error handling that
> was missing from V2 (in block/vvfat.c).
>
> The Fourth version is correctly handling EINTR error on read/write
> system calls. read/write calls are replaced by qemu_read/qemu_write
> functions that are handling EINTR and incomplete read/write under
> the cover.
>
> Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
>   

This really makes me nervous to be honest.  It's too much for one patch.

What I'd rather do, is commit Gerd's patch and also add 
-U_FORTIFY_SOURCE to the default CFLAGS.  I've confirmed this fixes the 
default build on Ubuntu.

I'd rather take this set of clean ups as a set of smaller, well 
thought-out patches.  Once that's done, we can remove -U_FORTIFY_SOURCE.

> ---
>  block.c           |    3 +-
>  block/bochs.c     |    3 +-
>  block/cow.c       |   12 +++++++++-
>  block/qcow.c      |   22 +++++++++++++++-----
>  block/qcow2.c     |   37 ++++++++++++++++++++++++++++-------
>  block/raw-posix.c |    9 +++++--
>  block/vmdk.c      |   54 +++++++++++++++++++++++++++++++++++-----------------
>  block/vvfat.c     |   24 ++++++++++++++++------
>  linux-user/mmap.c |    7 ++++-
>  linux-user/path.c |    6 ++++-
>  osdep.c           |    5 +++-
>  qemu-common.h     |   31 ++++++++++++++++++++++++++++++
>  slirp/misc.c      |    4 ++-
>  usb-linux.c       |    3 +-
>  vl.c              |   14 +++++++++---
>  15 files changed, 177 insertions(+), 57 deletions(-)
>
> diff --git a/block.c b/block.c
> index aca5a6d..c78d66a 100644
> --- a/block.c
> +++ b/block.c
> @@ -371,7 +371,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
>              snprintf(backing_filename, sizeof(backing_filename),
>                       "%s", filename);
>          else
> -            realpath(filename, backing_filename);
> +            if (!realpath(filename, backing_filename))
> +                return -1;

There should be cleanup work to do, no?

>  
>          bdrv_qcow2 = bdrv_find_format("qcow2");
>          options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
> diff --git a/block/bochs.c b/block/bochs.c
> index bac81c4..1fbce9e 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 (qemu_read(s->fd, &bitmap_entry, 1) != 1)
> +        return -1; // not allocated
>   

Why check errors on read but not lseek?  If we're going to add error 
checking to this function, we should make it robust, not just enough 
error checking to silence GCC.  We should just silence GCC with 
-U_FORTIFY_SOURCE.

The same is true for most of the remainder.  This is definitely a good 
task worth doing but I think we should do it more carefully.

Regards,

Anthony Liguori

  parent reply	other threads:[~2009-06-17 21:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-17 21:22 [Qemu-devel] [PATCH v4] avoid compilation warning/errors on up to date Jean-Christophe Dubois
2009-06-17 21:51 ` malc
2009-06-17 22:58   ` Jean-Christophe Dubois
2009-06-18  1:17     ` malc
2009-06-17 21:54 ` Anthony Liguori [this message]
2009-06-17 22:41   ` Jean-Christophe Dubois
2009-06-17 22:51     ` Anthony Liguori
2009-06-17 23:16       ` Jean-Christophe Dubois
2009-06-18 20:16         ` Luiz Capitulino
2009-06-18 20:33           ` Anthony Liguori
2009-06-18 21:05             ` Luiz Capitulino
2009-06-18 21:10             ` Jean-Christophe Dubois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A396630.20105@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=jcd@tribudubois.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.