qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] net: roll back qdev_prop_vlan


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] net: roll back qdev_prop_vlan
Date: Mon, 18 Jun 2012 11:22:19 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Jun 17, 2012 at 12:30:32AM +0800, address@hidden 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 via email to

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