All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Juan Quintela <quintela@trasno.org>, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 09/15] usb-linux.c: fix warning with _FORTIFY_SOURCE
Date: Tue, 5 Jan 2010 18:36:47 +0200	[thread overview]
Message-ID: <20100105163647.GA29552@redhat.com> (raw)
In-Reply-To: <cc557aab1001050807t58d2fd8dg57e4f3c1883e6824@mail.gmail.com>

On Tue, Jan 05, 2010 at 06:07:35PM +0200, Kirill A. Shutemov wrote:
> On Tue, Jan 5, 2010 at 4:42 PM, Juan Quintela <quintela@trasno.org> wrote:
> > "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 |    8 ++++++--
> >>  1 files changed, 6 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/usb-linux.c b/usb-linux.c
> >> index 88728e9..8673474 100644
> >> --- a/usb-linux.c
> >> +++ b/usb-linux.c
> >> @@ -1201,9 +1201,13 @@ 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;
> >> +        }
> >> +
> > This if is equivalent to:
> >
> > ret = !!fgets(line, line_size, f);
> >
> > No need for the if at all :)
> 
> It's not very readable.
> Probably better to use something like:
> 
> ret = (fgets(line, line_size, f) != NULL);
> 

Might be matter of taste. E.g. I think !! is more readable than != NULL.
And () around != are not needed.  It's better to make code brief IMO,
a lof of boilerplate hides bugs.

Nothing to get hung about though.

-- 
MST

  reply	other threads:[~2010-01-05 16:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-02  3:45 [Qemu-devel] [PATCH 01/15] Introduce qemu_write_full() Kirill A. Shutemov
2010-01-02  3:45 ` [Qemu-devel] [PATCH 02/15] posix-aio-compat.c: fix warning with _FORTIFY_SOURCE Kirill A. Shutemov
2010-01-02  3:45   ` [Qemu-devel] [PATCH 03/15] block/cow.c: fix warnings " Kirill A. Shutemov
2010-01-02  3:45     ` [Qemu-devel] [PATCH 04/15] block/qcow.c: " Kirill A. Shutemov
2010-01-02  3:45       ` [Qemu-devel] [PATCH 05/15] block/vmdk.o: " Kirill A. Shutemov
2010-01-02  3:45         ` [Qemu-devel] [PATCH 06/15] block/vvfat.c: " Kirill A. Shutemov
2010-01-02  3:45           ` [Qemu-devel] [PATCH 07/15] block/qcow2.c: " Kirill A. Shutemov
2010-01-02  3:45             ` [Qemu-devel] [PATCH 08/15] net/slirp.c: fix warning " Kirill A. Shutemov
2010-01-02  3:45               ` [Qemu-devel] [PATCH 09/15] usb-linux.c: " Kirill A. Shutemov
2010-01-02  3:45                 ` [Qemu-devel] [PATCH 10/15] vl.c: " Kirill A. Shutemov
2010-01-02  3:45                   ` [Qemu-devel] [PATCH 11/15] monitor.c: fix warnings " Kirill A. Shutemov
2010-01-02  3:45                     ` [Qemu-devel] [PATCH 12/15] linux-user/mmap.c: " Kirill A. Shutemov
2010-01-02  3:45                       ` [Qemu-devel] [PATCH 13/15] Enable _FORTIFY_SOURCE=2 Kirill A. Shutemov
2010-01-02  3:45                         ` [Qemu-devel] [PATCH 14/15] Add -fstack-protector-all to CFLAGS Kirill A. Shutemov
2010-01-02  3:45                           ` [Qemu-devel] [PATCH 15/15] linux-user: fix return value of mmap_frag() Kirill A. Shutemov
     [not found]                 ` <m3zl4svci4.fsf@neno.neno>
2010-01-05 16:07                   ` [Qemu-devel] Re: [PATCH 09/15] usb-linux.c: fix warning with _FORTIFY_SOURCE Kirill A. Shutemov
2010-01-05 16:36                     ` Michael S. Tsirkin [this message]
2010-01-02 10:34 ` [Qemu-devel] Re: [PATCH 01/15] Introduce qemu_write_full() Paolo Bonzini

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=20100105163647.GA29552@redhat.com \
    --to=mst@redhat.com \
    --cc=kirill@shutemov.name \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@trasno.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.