All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] usb/vmstate: add parent dev path
Date: Thu, 22 Mar 2012 13:17:05 +0100	[thread overview]
Message-ID: <4F6B1841.7050000@redhat.com> (raw)
In-Reply-To: <1332418064-23091-1-git-send-email-kraxel@redhat.com>

Il 22/03/2012 13:07, Gerd Hoffmann ha scritto:
> @@ -460,7 +462,21 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
>  static char *usb_get_dev_path(DeviceState *qdev)
>  {
>      USBDevice *dev = USB_DEVICE(qdev);
> -    return g_strdup(dev->port->path);
> +    DeviceState *hcd = qdev->parent_bus->parent;
> +    char *id = NULL;
> +
> +    if ((dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) &&
> +        hcd && hcd->parent_bus && hcd->parent_bus->info->get_dev_path) {
> +        id = hcd->parent_bus->info->get_dev_path(hcd);
> +    }
> +    if (id) {
> +        int len = strlen(id)+strlen(dev->port->path)+2;
> +        char *ret = g_malloc(len);
> +        snprintf(ret, len, "%s/%s", id, dev->port->path);

You can use g_strdup_printf here, also this is leaking id (I have to fix
it for SCSI too).

> +        return ret;
> +    } else {
> +        return g_strdup(dev->port->path);
> +    }
>  }
>  
>  static char *usb_get_fw_dev_path(DeviceState *qdev)

Paolo

  reply	other threads:[~2012-03-22 12:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22 12:07 [Qemu-devel] [PATCH] usb/vmstate: add parent dev path Gerd Hoffmann
2012-03-22 12:17 ` Paolo Bonzini [this message]
2012-03-22 14:01 ` Andreas Färber
2012-03-22 14:37   ` Gerd Hoffmann
2012-03-22 15:12     ` Andreas Färber
2012-03-28 22:08       ` Michael Roth

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=4F6B1841.7050000@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.