qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Programmingkid <programmingkidx@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] hw/usb/bus.c: print device ID when 'info usb' used
Date: Fri, 28 Aug 2015 14:50:01 +0100	[thread overview]
Message-ID: <20150828135001.GR28526@redhat.com> (raw)
In-Reply-To: <E37F6880-6876-4625-8F22-9F8A939B8F91@gmail.com>

On Fri, Aug 28, 2015 at 09:39:43AM -0400, Programmingkid wrote:
> 
> On Aug 28, 2015, at 9:35 AM, Daniel P. Berrange wrote:
> 
> > On Fri, Aug 28, 2015 at 09:08:12AM -0400, Programmingkid wrote:
> >> 
> >> On Aug 28, 2015, at 7:50 AM, Gerd Hoffmann wrote:
> >> 
> >>> On Mo, 2015-08-24 at 15:13 -0400, Programmingkid wrote:
> >>>> +            monitor_printf(mon, "  Device %d.%d, Port %s, Speed %s
> >>>> Mb/s,"
> >>>> +                                "Product %s, ID %s\n",
> >>>> +                           bus->busnr, dev->addr, port->path,
> >>>> +                           usb_speed(dev->speed),
> >>>> +                           dev->product_desc, dev->qdev.id);
> >>>> 
> >>> 
> >>> dev->qdev.id can be NULL.
> >>> 
> >>> cheers,
> >>> Gerd
> >> 
> >> That isn't a problem. It will just say "null" when it is printed.
> >> No crash or garbage text.
> > 
> > Handling of '%s' with NULL is undefined by the standard. Linux
> > glibc prints the string "null", but other implementations can
> > crash.
> 
> "null" is also printed on Mac OS X.

I don't know if it is still true in latest versions, but historically
Solaris would crash on NULL.

  "The problem is that while you can printf("%s",NULL); in most
   Linux distributions, doing the same in Solaris caused the
   executable to exit and generate a core."

  https://blogs.oracle.com/bnitz/entry/asc_and_sprintf_s_null

> Do you want dev->qdev.id replaced with this? (dev->qdev.id != NULL) ? dev->qdev.id : "null"

It can be a bit shorter if you just leave out the "!= NULL" bit and
rely on implicit conversion of non-null to a boolean true. I'm not
sure if QEMU has a macro wrapper for hiding this possibly.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2015-08-28 13:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24 19:13 [Qemu-devel] [PATCH] hw/usb/bus.c: print device ID when 'info usb' used Programmingkid
2015-08-28 11:50 ` Gerd Hoffmann
2015-08-28 13:08   ` Programmingkid
2015-08-28 13:35     ` Daniel P. Berrange
2015-08-28 13:39       ` Programmingkid
2015-08-28 13:50         ` Daniel P. Berrange [this message]
2015-08-28 13:50         ` Gerd Hoffmann
2015-08-28 13:55           ` Programmingkid
2015-08-28 16:07             ` Peter Maydell
2015-08-28 16:09               ` Programmingkid

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=20150828135001.GR28526@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=programmingkidx@gmail.com \
    --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 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).