From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYkl-0001To-T4 for qemu-devel@nongnu.org; Thu, 18 Sep 2014 06:16:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUYkg-0006gf-Sw for qemu-devel@nongnu.org; Thu, 18 Sep 2014 06:15:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYkg-0006fc-Id for qemu-devel@nongnu.org; Thu, 18 Sep 2014 06:15:50 -0400 Message-ID: <541AB0C8.3080507@redhat.com> Date: Thu, 18 Sep 2014 12:15:36 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1411032780-10692-1-git-send-email-arei.gonglei@huawei.com> <1411032780-10692-15-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1411032780-10692-15-git-send-email-arei.gonglei@huawei.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 14/19] dev-hid: convert init to realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com, qemu-devel@nongnu.org Cc: luonengjun@huawei.com, peter.huangpeng@huawei.com, weidong.huang@huawei.com, kraxel@redhat.com, armbru@redhat.com Il 18/09/2014 11:32, arei.gonglei@huawei.com ha scritto: > From: Gonglei > > In this way, all the implementations now use > error_setg instead of error_report for reporting error. > > Signed-off-by: Gonglei > --- > hw/usb/dev-hid.c | 23 +++++++++++------------ > 1 file changed, 11 insertions(+), 12 deletions(-) > > diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c > index 67a57f1..7e9d2d6 100644 > --- a/hw/usb/dev-hid.c > +++ b/hw/usb/dev-hid.c > @@ -582,7 +582,7 @@ static int usb_hid_initfn(USBDevice *dev, int kind) > return 0; Please change usb_hid_initfn to return void. > } > > -static int usb_tablet_initfn(USBDevice *dev) > +static void usb_tablet_realize(USBDevice *dev, Error **errp) > { > USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev); > > @@ -594,22 +594,21 @@ static int usb_tablet_initfn(USBDevice *dev) > dev->usb_desc = &desc_tablet2; > break; > default: > - error_report("Invalid usb version %d for usb-tabler (must be 1 or 2)", > - us->usb_version); > - return -1; > + error_setg(errp, "Invalid usb version %d for usb-tablet " > + "(must be 1 or 2)", us->usb_version); Missing return here. Paolo > } > > - return usb_hid_initfn(dev, HID_TABLET); > + usb_hid_initfn(dev, HID_TABLET); > } > > -static int usb_mouse_initfn(USBDevice *dev) > +static void usb_mouse_realize(USBDevice *dev, Error **errp) > { > - return usb_hid_initfn(dev, HID_MOUSE); > + usb_hid_initfn(dev, HID_MOUSE); > } > > -static int usb_keyboard_initfn(USBDevice *dev) > +static void usb_keyboard_realize(USBDevice *dev, Error **errp) > { > - return usb_hid_initfn(dev, HID_KEYBOARD); > + usb_hid_initfn(dev, HID_KEYBOARD); > } > > static int usb_ptr_post_load(void *opaque, int version_id) > @@ -669,7 +668,7 @@ static void usb_tablet_class_initfn(ObjectClass *klass, void *data) > USBDeviceClass *uc = USB_DEVICE_CLASS(klass); > > usb_hid_class_initfn(klass, data); > - uc->init = usb_tablet_initfn; > + uc->realize = usb_tablet_realize; > uc->product_desc = "QEMU USB Tablet"; > dc->vmsd = &vmstate_usb_ptr; > dc->props = usb_tablet_properties; > @@ -689,7 +688,7 @@ static void usb_mouse_class_initfn(ObjectClass *klass, void *data) > USBDeviceClass *uc = USB_DEVICE_CLASS(klass); > > usb_hid_class_initfn(klass, data); > - uc->init = usb_mouse_initfn; > + uc->realize = usb_mouse_realize; > uc->product_desc = "QEMU USB Mouse"; > uc->usb_desc = &desc_mouse; > dc->vmsd = &vmstate_usb_ptr; > @@ -714,7 +713,7 @@ static void usb_keyboard_class_initfn(ObjectClass *klass, void *data) > USBDeviceClass *uc = USB_DEVICE_CLASS(klass); > > usb_hid_class_initfn(klass, data); > - uc->init = usb_keyboard_initfn; > + uc->realize = usb_keyboard_realize; > uc->product_desc = "QEMU USB Keyboard"; > uc->usb_desc = &desc_keyboard; > dc->vmsd = &vmstate_usb_kbd; >