qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/2] block: Add bs->node_name to hold the name o


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH 1/2] block: Add bs->node_name to hold the name of a bs node of the bs graph.
Date: Fri, 8 Nov 2013 10:51:11 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Am 07.11.2013 um 21:23 hat Eric Blake geschrieben:
> On 11/07/2013 08:01 AM, Benoît Canet wrote:
> > Add the minimum of code to prepare the followings patches.
> > 
> > If no node_name is provided to bdrv_new the bs->node_name is set to 
> > "undefined".
> > This will allow to have some default string to communicate in QMP and HMP.
> > This also make "undefined" a reserved string for bs->node_name.
> > 
> > Signed-off-by: Benoit Canet <address@hidden>
> > ---
> 
> > +    /* if node name is given store it in bs and insert bs in the graph bs 
> > list
> > +     * note: undefined is a reserved node name
> > +     */
> > +    if (node_name &&
> > +        node_name[0] != '\0' &&
> > +        strcmp(node_name, "undefined")) {
> > +        pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
> > +        QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
> > +    /* else set the bs node name to undefined for QMP and HMP */
> > +    } else {
> > +        sprintf(bs->node_name, "undefined");
> 
> strcpy() is more efficient than sprintf() with no % in the format string.

pstrcpy() please, even if the string is currently clearly short enough
for the buffer size.

Or well, get rid of the "undefined" string in favour of NULL or "", then
you don't even have to think about this. The magic "undefined" value is
ugly anyway.

Kevin

Attachment: pgpWng5GOIPsP.pgp
Description: PGP signature


reply via email to

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