fix qdev_print_devinfo()
snprintf returns number of bytes needed for the output, not the number of bytes actually written. Thus the math is wrong ... Spotted by Markus Armbruster. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
This commit is contained in:
parent
ea2b7271bf
commit
22f2e34474
24
hw/qdev.c
24
hw/qdev.c
|
@ -108,15 +108,23 @@ DeviceState *qdev_create(BusState *bus, const char *name)
|
||||||
static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len)
|
static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
pos += snprintf(dest+pos, len-pos, "name \"%s\", bus %s",
|
ret = snprintf(dest+pos, len-pos, "name \"%s\", bus %s",
|
||||||
info->name, info->bus_info->name);
|
info->name, info->bus_info->name);
|
||||||
if (info->alias)
|
pos += MIN(len-pos,ret);
|
||||||
pos += snprintf(dest+pos, len-pos, ", alias \"%s\"", info->alias);
|
if (info->alias) {
|
||||||
if (info->desc)
|
ret = snprintf(dest+pos, len-pos, ", alias \"%s\"", info->alias);
|
||||||
pos += snprintf(dest+pos, len-pos, ", desc \"%s\"", info->desc);
|
pos += MIN(len-pos,ret);
|
||||||
if (info->no_user)
|
}
|
||||||
pos += snprintf(dest+pos, len-pos, ", no-user");
|
if (info->desc) {
|
||||||
|
ret = snprintf(dest+pos, len-pos, ", desc \"%s\"", info->desc);
|
||||||
|
pos += MIN(len-pos,ret);
|
||||||
|
}
|
||||||
|
if (info->no_user) {
|
||||||
|
ret = snprintf(dest+pos, len-pos, ", no-user");
|
||||||
|
pos += MIN(len-pos,ret);
|
||||||
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue