Good catch, thanks, please next version.

On Mon, Jun 18, 2012 at 6:22 PM, Stefan Hajnoczi
<stefa...@linux.vnet.ibm.com> wrote:
> On Sun, Jun 17, 2012 at 12:30:32AM +0800, zwu.ker...@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
>



-- 
Regards,

Zhi Yong Wu

Reply via email to