From nobody Thu May 2 05:25:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492345635275416.0204703439781; Sun, 16 Apr 2017 05:27:15 -0700 (PDT) Received: from localhost ([::1]:60444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czjGr-0001X0-9l for importer@patchew.org; Sun, 16 Apr 2017 08:27:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czjG1-00014k-Fo for qemu-devel@nongnu.org; Sun, 16 Apr 2017 08:26:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1czjFy-0000So-Aj for qemu-devel@nongnu.org; Sun, 16 Apr 2017 08:26:21 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:34348) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1czjFy-0000Rf-3K for qemu-devel@nongnu.org; Sun, 16 Apr 2017 08:26:18 -0400 Received: by mail-pf0-x244.google.com with SMTP id g23so6204615pfj.1 for ; Sun, 16 Apr 2017 05:26:17 -0700 (PDT) Received: from fma-dfsg.ipads-lab.se.sjtu.edu.cn ([69.85.85.101]) by smtp.gmail.com with ESMTPSA id m20sm12554585pgd.32.2017.04.16.05.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 16 Apr 2017 05:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fa69NZhTxdLMyIm0YdMhG4cXtHwenHpRn3WaU3s5srs=; b=naI19uZiIbluNnjdCVADkkzTOjxXIekATUmGxS2wfCoXNuE7/KJdsAeE5+ERGLUH8s woAnHdaJ76UZkLpcNroA2WSfJt/UojE/wK3mdl4rVJL1elxKstVGbM41W1p7bbm4A9ID 6qVhZb2FgtTKSxJJkgvym5b6He6rN99yEKLa/cLmp1+cgDj5jy1sXLWM/Q8fwWkYMZRm qYqK1U2gCn37kjkPmJwLYo9quJFGw1utvjD4Fk+68TBICDFKlj+SY2pX2nMTv+tftqwC WRJ3x8/l8hlI8TjpG0cRaW9JnLBKYGw4VsijBtmDimb07scbGYpJS6MeO5ILFhnvemq/ nprg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fa69NZhTxdLMyIm0YdMhG4cXtHwenHpRn3WaU3s5srs=; b=B4cau5ktxBatAPgnY8psKvZdqYa6orJC09XYH26hLHgyfh1hegCel1w1pUIpM/pWYR m04aAVf8esIKo1m1dKxPJE9IS5UeJSrF7Hhm++O+snDIpd3nVYuLerRxB10k5f8ZsjD1 p/ubJP1lKmHdyaTyj+P5+VEyTpVIWAOpLGi8HTvuKCUQyXMP3QCNfVPDGlUF0FUlGn/Q ii+nj1iI4x5+46go7oEdGePtDYsAyVZ7Hkx61Uud9cOuhHoJvVDavpsmdk5SWGcSa/ut T7WVZxLWpufiwnBlPAu4SKfotMPDoat2NEx1WRgdozkDP1fXr7mcS79Tna3+5ONSP3jx UBOw== X-Gm-Message-State: AN3rC/4gTjHiWIDB15P52GUKpuOwrDjNrJ8ciI/sLrKMSGo487H5aNqY 0+hJT4zwpQSstg== X-Received: by 10.84.129.67 with SMTP id 61mr9271072plb.16.1492345576849; Sun, 16 Apr 2017 05:26:16 -0700 (PDT) From: Zihan Yang To: qemu-devel@nongnu.org Date: Sun, 16 Apr 2017 20:26:01 +0800 Message-Id: <1492345561-10267-1-git-send-email-tgnyang@gmail.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH] hw: make *_exit functions return void X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Alexander Graf , Christian Borntraeger , Gerd Hoffmann , Cornelia Huck , Paolo Bonzini , Zihan Yang , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" According to the second suggestion listed on Dead code Removal of BiteSizedTasks, I modify some *_exit functions to make them return void. Some *_exit and *_exitfn functions that already return void remain unchanged. Also, the checks for the callers are deleted. Signed-off-by: Zihan Yang --- hw/audio/hda-codec.c | 3 +-- hw/audio/intel-hda.c | 3 +-- hw/audio/intel-hda.h | 2 +- hw/char/sclpconsole-lm.c | 3 +-- hw/char/sclpconsole.c | 3 +-- hw/core/qdev.c | 6 +----- hw/s390x/event-facility.c | 6 +----- hw/s390x/virtio-ccw.c | 7 +++---- hw/s390x/virtio-ccw.h | 2 +- hw/usb/dev-smartcard-reader.c | 3 +-- include/hw/qdev-core.h | 2 +- include/hw/s390x/event-facility.h | 2 +- 12 files changed, 14 insertions(+), 28 deletions(-) diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 52d4640..5402cd1 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -520,7 +520,7 @@ static int hda_audio_init(HDACodecDevice *hda, const st= ruct desc_codec *desc) return 0; } =20 -static int hda_audio_exit(HDACodecDevice *hda) +static void hda_audio_exit(HDACodecDevice *hda) { HDAAudioState *a =3D HDA_AUDIO(hda); HDAAudioStream *st; @@ -539,7 +539,6 @@ static int hda_audio_exit(HDACodecDevice *hda) } } AUD_remove_card(&a->card); - return 0; } =20 static int hda_audio_post_load(void *opaque, int version) diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 537face..991c704 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -70,7 +70,7 @@ static void hda_codec_dev_realize(DeviceState *qdev, Erro= r **errp) } } =20 -static int hda_codec_dev_exit(DeviceState *qdev) +static void hda_codec_dev_exit(DeviceState *qdev) { HDACodecDevice *dev =3D HDA_CODEC_DEVICE(qdev); HDACodecDeviceClass *cdc =3D HDA_CODEC_DEVICE_GET_CLASS(dev); @@ -78,7 +78,6 @@ static int hda_codec_dev_exit(DeviceState *qdev) if (cdc->exit) { cdc->exit(dev); } - return 0; } =20 HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad) diff --git a/hw/audio/intel-hda.h b/hw/audio/intel-hda.h index d784bcf..53b78da 100644 --- a/hw/audio/intel-hda.h +++ b/hw/audio/intel-hda.h @@ -38,7 +38,7 @@ typedef struct HDACodecDeviceClass DeviceClass parent_class; =20 int (*init)(HDACodecDevice *dev); - int (*exit)(HDACodecDevice *dev); + void (*exit)(HDACodecDevice *dev); void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data); void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running, bool = output); } HDACodecDeviceClass; diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 07d6ebd..6fa8922 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -318,9 +318,8 @@ static int console_init(SCLPEvent *event) return 0; } =20 -static int console_exit(SCLPEvent *event) +static void console_exit(SCLPEvent *event) { - return 0; } =20 static void console_reset(DeviceState *dev) diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c index b78f240..d9bbc5e 100644 --- a/hw/char/sclpconsole.c +++ b/hw/char/sclpconsole.c @@ -246,9 +246,8 @@ static void console_reset(DeviceState *dev) scon->notify =3D false; } =20 -static int console_exit(SCLPEvent *event) +static void console_exit(SCLPEvent *event) { - return 0; } =20 static Property console_properties[] =3D { diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 1e7fb33..5415843 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -238,11 +238,7 @@ static void device_unrealize(DeviceState *dev, Error *= *errp) DeviceClass *dc =3D DEVICE_GET_CLASS(dev); =20 if (dc->exit) { - int rc =3D dc->exit(dev); - if (rc < 0) { - error_setg(errp, "Device exit failed."); - return; - } + dc->exit(dev); } } =20 diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 34b2faf..f7c509c 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -413,11 +413,7 @@ static void event_unrealize(DeviceState *qdev, Error *= *errp) SCLPEvent *event =3D SCLP_EVENT(qdev); SCLPEventClass *child =3D SCLP_EVENT_GET_CLASS(event); if (child->exit) { - int rc =3D child->exit(event); - if (rc < 0) { - error_setg(errp, "SCLP event exit failed."); - return; - } + child->exit(event); } } =20 diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 00b3bde..d1c4ff6 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -722,7 +722,7 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *= dev, Error **errp) } } =20 -static int virtio_ccw_exit(VirtioCcwDevice *dev) +static void virtio_ccw_exit(VirtioCcwDevice *dev) { CcwDevice *ccw_dev =3D CCW_DEVICE(dev); SubchDev *sch =3D ccw_dev->sch; @@ -735,7 +735,6 @@ static int virtio_ccw_exit(VirtioCcwDevice *dev) release_indicator(&dev->routes.adapter, dev->indicators); dev->indicators =3D NULL; } - return 0; } =20 static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp) @@ -1616,12 +1615,12 @@ static void virtio_ccw_busdev_realize(DeviceState *= dev, Error **errp) virtio_ccw_device_realize(_dev, errp); } =20 -static int virtio_ccw_busdev_exit(DeviceState *dev) +static void virtio_ccw_busdev_exit(DeviceState *dev) { VirtioCcwDevice *_dev =3D (VirtioCcwDevice *)dev; VirtIOCCWDeviceClass *_info =3D VIRTIO_CCW_DEVICE_GET_CLASS(dev); =20 - return _info->exit(_dev); + _info->exit(_dev); } =20 static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev, diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h index 41d4010..ce8baa3 100644 --- a/hw/s390x/virtio-ccw.h +++ b/hw/s390x/virtio-ccw.h @@ -74,7 +74,7 @@ typedef struct VirtioCcwDevice VirtioCcwDevice; typedef struct VirtIOCCWDeviceClass { CCWDeviceClass parent_class; void (*realize)(VirtioCcwDevice *dev, Error **errp); - int (*exit)(VirtioCcwDevice *dev); + void (*exit)(VirtioCcwDevice *dev); } VirtIOCCWDeviceClass; =20 /* Performance improves when virtqueue kick processing is decoupled from t= he diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 757b8b3..71e3667 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -1289,7 +1289,7 @@ void ccid_card_card_inserted(CCIDCardState *card) ccid_on_slot_change(s, true); } =20 -static int ccid_card_exit(DeviceState *qdev) +static void ccid_card_exit(DeviceState *qdev) { CCIDCardState *card =3D CCID_CARD(qdev); USBDevice *dev =3D USB_DEVICE(qdev->parent_bus->parent); @@ -1300,7 +1300,6 @@ static int ccid_card_exit(DeviceState *qdev) } ccid_card_exitfn(card); s->card =3D NULL; - return 0; } =20 static int ccid_card_init(DeviceState *qdev) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index b44b476..0efd9e9 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -31,7 +31,7 @@ typedef enum DeviceCategory { } DeviceCategory; =20 typedef int (*qdev_initfn)(DeviceState *dev); -typedef int (*qdev_event)(DeviceState *dev); +typedef void (*qdev_event)(DeviceState *dev); typedef void (*qdev_resetfn)(DeviceState *dev); typedef void (*DeviceRealize)(DeviceState *dev, Error **errp); typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp); diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-fac= ility.h index def1bb0..1a32f3a 100644 --- a/include/hw/s390x/event-facility.h +++ b/include/hw/s390x/event-facility.h @@ -162,7 +162,7 @@ typedef struct SCLPEvent { typedef struct SCLPEventClass { DeviceClass parent_class; int (*init)(SCLPEvent *event); - int (*exit)(SCLPEvent *event); + void (*exit)(SCLPEvent *event); =20 /* get SCLP's send mask */ unsigned int (*get_send_mask)(void); --=20 2.7.4