qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: zwu.kernel@gmail.com
Cc: nzini@redhat.com, Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] net: roll back qdev_prop_vlan
Date: Mon, 18 Jun 2012 11:22:19 +0100	[thread overview]
Message-ID: <20120618102219.GA5406@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <1339864232-9171-1-git-send-email-zwu.kernel@gmail.com>

On Sun, Jun 17, 2012 at 12:30:32AM +0800, zwu.kernel@gmail.com wrote:
> +static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)
> +{
> +    NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
> +
> +    if (*ptr) {
> +        unsigned int id;
> +        if (!net_hub_id_for_client(*ptr, &id)) {
> +            return snprintf(dest, len, "%d", id);

Unsigned int should be %u.  Source code scanners or the compiler could
warn about this so it's worth changing.

> +        }
> +    }
> +
> +    return snprintf(dest, len, "<null>");
> +}
> +
> +static void get_vlan(Object *obj, Visitor *v, void *opaque,
> +                     const char *name, Error **errp)
> +{
> +    DeviceState *dev = DEVICE(obj);
> +    Property *prop = opaque;
> +    NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
> +    int64_t id = -1;
> +
> +    if (*ptr) {
> +        unsigned int hub_id;
> +        net_hub_id_for_client(*ptr, &hub_id);

It's unclear what happens if net_hub_id_for_client() fails but it looks
like hub_id may be uninitialized.

Stefan

  reply	other threads:[~2012-06-18 10:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-16 16:30 [Qemu-devel] [PATCH] net: roll back qdev_prop_vlan zwu.kernel
2012-06-18 10:22 ` Stefan Hajnoczi [this message]
2012-06-18 12:48   ` Zhi Yong Wu

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=20120618102219.GA5406@stefanha-thinkpad.localdomain \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=nzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wuzhy@linux.vnet.ibm.com \
    --cc=zwu.kernel@gmail.com \
    /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).