qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] hw/usb/bus.c: print device ID when 'info usb' u


From: Daniel P. Berrange
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
User-agent: Mutt/1.5.23 (2014-03-12)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]