All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Michael Roth" <mdroth@linux.vnet.ibm.com>,
	"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
	qemu-trivial@nongnu.org, "Alexander Graf" <agraf@suse.de>,
	qemu-devel@nongnu.org, "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers
Date: Thu, 23 Mar 2017 14:56:46 +0100	[thread overview]
Message-ID: <1490277406.13302.1.camel@redhat.com> (raw)
In-Reply-To: <87tw6ktban.fsf@dusky.pond.sub.org>

On Do, 2017-03-23 at 13:41 +0100, Markus Armbruster wrote:
> Gerd Hoffmann <kraxel@redhat.com> writes:
> 
> >   Hi,
> >
> >>  oops, there are hard-coded calls with NULL/0. I suppose to fix clang
> >> warning, it would need to check if data != null for memcpy.
> >
> > I'd check for len > 0, and in that if branch we can also assert on data
> > == NULL and thereby check that len and data are consistent.
> 
> If len is non-zero but data is null, memcpy() will crash just fine by
> itself, so why bother asserting.

To make clang happy?  But maybe clang is clever enough to figure data
can't be null at that point in case we call memcpy with len != 0
only ...

cheers,
  Gerd



WARNING: multiple messages have this Message-ID (diff)
From: Gerd Hoffmann <kraxel@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Michael Roth" <mdroth@linux.vnet.ibm.com>,
	"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
	qemu-trivial@nongnu.org, "Alexander Graf" <agraf@suse.de>,
	qemu-devel@nongnu.org, "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers
Date: Thu, 23 Mar 2017 14:56:46 +0100	[thread overview]
Message-ID: <1490277406.13302.1.camel@redhat.com> (raw)
In-Reply-To: <87tw6ktban.fsf@dusky.pond.sub.org>

On Do, 2017-03-23 at 13:41 +0100, Markus Armbruster wrote:
> Gerd Hoffmann <kraxel@redhat.com> writes:
> 
> >   Hi,
> >
> >>  oops, there are hard-coded calls with NULL/0. I suppose to fix clang
> >> warning, it would need to check if data != null for memcpy.
> >
> > I'd check for len > 0, and in that if branch we can also assert on data
> > == NULL and thereby check that len and data are consistent.
> 
> If len is non-zero but data is null, memcpy() will crash just fine by
> itself, so why bother asserting.

To make clang happy?  But maybe clang is clever enough to figure data
can't be null at that point in case we call memcpy with len != 0
only ...

cheers,
  Gerd

  reply	other threads:[~2017-03-23 13:57 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 20:48 [Qemu-trivial] [PATCH RESEND 0/3] easy-to-fix clang warnings Philippe Mathieu-Daudé
2017-03-22 20:48 ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-03-22 20:48 ` [Qemu-trivial] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers Philippe Mathieu-Daudé
2017-03-22 20:48   ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-03-23  6:49   ` [Qemu-trivial] " Markus Armbruster
2017-03-23  6:49     ` Markus Armbruster
2017-03-23  7:43     ` [Qemu-trivial] " Gerd Hoffmann
2017-03-23  7:43       ` Gerd Hoffmann
2017-03-23  8:14       ` [Qemu-trivial] " Marc-André Lureau
2017-03-23  8:14         ` Marc-André Lureau
2017-03-23  9:51         ` [Qemu-trivial] " Gerd Hoffmann
2017-03-23  9:51           ` Gerd Hoffmann
2017-03-23 12:41           ` [Qemu-trivial] " Markus Armbruster
2017-03-23 12:41             ` Markus Armbruster
2017-03-23 13:56             ` Gerd Hoffmann [this message]
2017-03-23 13:56               ` Gerd Hoffmann
2017-03-23 14:08               ` [Qemu-trivial] " Markus Armbruster
2017-03-23 14:08                 ` Markus Armbruster
2017-04-07 21:33                 ` [Qemu-trivial] " Philippe Mathieu-Daudé
2017-04-07 21:33                   ` Philippe Mathieu-Daudé
2017-03-22 20:48 ` [Qemu-trivial] [PATCH RESEND 2/3] device_tree: fix compiler warnings (clang 5) Philippe Mathieu-Daudé
2017-03-22 20:48   ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-03-22 22:35   ` [Qemu-trivial] " Marc-André Lureau
2017-03-22 22:35     ` Marc-André Lureau
2017-03-22 20:48 ` [Qemu-trivial] [PATCH RESEND 3/3] qga: " Philippe Mathieu-Daudé
2017-03-22 20:48   ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-03-22 21:22   ` [Qemu-trivial] " Michael Roth
2017-03-22 21:22     ` [Qemu-devel] " Michael Roth
2017-04-07 21:31     ` [Qemu-trivial] " Philippe Mathieu-Daudé
2017-04-07 21:31       ` Philippe Mathieu-Daudé

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=1490277406.13302.1.camel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=marcandre.lureau@gmail.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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.