1072c8
From 5cf6dd33456c4e7e2a8849f458ce234fb5bb290c Mon Sep 17 00:00:00 2001
1072c8
From: Kevin Wolf <kwolf@redhat.com>
1072c8
Date: Fri, 25 Jun 2021 17:41:03 -0400
1072c8
Subject: [PATCH 3/4] Compress lines for immediate return
1072c8
MIME-Version: 1.0
1072c8
Content-Type: text/plain; charset=UTF-8
1072c8
Content-Transfer-Encoding: 8bit
1072c8
1072c8
RH-Author: Kevin Wolf <kwolf@redhat.com>
1072c8
Message-id: <20210625174104.44313-2-kwolf@redhat.com>
1072c8
Patchwork-id: 101777
1072c8
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 1/2] Compress lines for immediate return
1072c8
Bugzilla: 1970912
1072c8
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
1072c8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1072c8
RH-Acked-by: Thomas Huth <thuth@redhat.com>
1072c8
1072c8
From: Simran Singhal <singhalsimran0@gmail.com>
1072c8
1072c8
Compress two lines into a single line if immediate return statement is found.
1072c8
1072c8
It also remove variables progress, val, data, ret and sock
1072c8
as they are no longer needed.
1072c8
1072c8
Remove space between function "mixer_load" and '(' to fix the
1072c8
checkpatch.pl error:-
1072c8
ERROR: space prohibited between function name and open parenthesis '('
1072c8
1072c8
Done using following coccinelle script:
1072c8
@@
1072c8
local idexpression ret;
1072c8
expression e;
1072c8
@@
1072c8
1072c8
-ret =
1072c8
+return
1072c8
     e;
1072c8
-return ret;
1072c8
1072c8
Signed-off-by: Simran Singhal <singhalsimran0@gmail.com>
1072c8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
1072c8
Message-Id: <20200401165314.GA3213@simran-Inspiron-5558>
1072c8
[lv: in handle_aiocb_write_zeroes_unmap() move "int ret" inside the #ifdef]
1072c8
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
1072c8
(cherry picked from commit b3ac2b94cdc939a90d5a22338ae507689e2cfab0)
1072c8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1072c8
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
1072c8
---
1072c8
 block/file-posix.c      | 8 +++-----
1072c8
 block/nfs.c             | 3 +--
1072c8
 block/nvme.c            | 4 +---
1072c8
 block/vhdx.c            | 3 +--
1072c8
 hw/audio/ac97.c         | 4 +---
1072c8
 hw/audio/adlib.c        | 5 +----
1072c8
 hw/display/cirrus_vga.c | 4 +---
1072c8
 migration/ram.c         | 4 +---
1072c8
 ui/gtk.c                | 3 +--
1072c8
 util/qemu-sockets.c     | 5 +----
1072c8
 10 files changed, 12 insertions(+), 31 deletions(-)
1072c8
1072c8
diff --git a/block/file-posix.c b/block/file-posix.c
1072c8
index 371572f1b0..837edcf027 100644
1072c8
--- a/block/file-posix.c
1072c8
+++ b/block/file-posix.c
1072c8
@@ -1626,13 +1626,12 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
1072c8
 {
1072c8
     RawPosixAIOData *aiocb = opaque;
1072c8
     BDRVRawState *s G_GNUC_UNUSED = aiocb->bs->opaque;
1072c8
-    int ret;
1072c8
 
1072c8
     /* First try to write zeros and unmap at the same time */
1072c8
 
1072c8
 #ifdef CONFIG_FALLOCATE_PUNCH_HOLE
1072c8
-    ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
1072c8
-                       aiocb->aio_offset, aiocb->aio_nbytes);
1072c8
+    int ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
1072c8
+                           aiocb->aio_offset, aiocb->aio_nbytes);
1072c8
     if (ret != -ENOTSUP) {
1072c8
         return ret;
1072c8
     }
1072c8
@@ -1640,8 +1639,7 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
1072c8
 
1072c8
     /* If we couldn't manage to unmap while guaranteed that the area reads as
1072c8
      * all-zero afterwards, just write zeroes without unmapping */
1072c8
-    ret = handle_aiocb_write_zeroes(aiocb);
1072c8
-    return ret;
1072c8
+    return handle_aiocb_write_zeroes(aiocb);
1072c8
 }
1072c8
 
1072c8
 #ifndef HAVE_COPY_FILE_RANGE
1072c8
diff --git a/block/nfs.c b/block/nfs.c
1072c8
index 2393fbfe6b..18c0a73694 100644
1072c8
--- a/block/nfs.c
1072c8
+++ b/block/nfs.c
1072c8
@@ -623,8 +623,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
1072c8
     }
1072c8
 
1072c8
     bs->total_sectors = ret;
1072c8
-    ret = 0;
1072c8
-    return ret;
1072c8
+    return 0;
1072c8
 }
1072c8
 
1072c8
 static QemuOptsList nfs_create_opts = {
1072c8
diff --git a/block/nvme.c b/block/nvme.c
1072c8
index 7b7c0cc5d6..eb2f54dd9d 100644
1072c8
--- a/block/nvme.c
1072c8
+++ b/block/nvme.c
1072c8
@@ -575,11 +575,9 @@ static bool nvme_poll_cb(void *opaque)
1072c8
 {
1072c8
     EventNotifier *e = opaque;
1072c8
     BDRVNVMeState *s = container_of(e, BDRVNVMeState, irq_notifier);
1072c8
-    bool progress = false;
1072c8
 
1072c8
     trace_nvme_poll_cb(s);
1072c8
-    progress = nvme_poll_queues(s);
1072c8
-    return progress;
1072c8
+    return nvme_poll_queues(s);
1072c8
 }
1072c8
 
1072c8
 static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
1072c8
diff --git a/block/vhdx.c b/block/vhdx.c
1072c8
index 21497f7318..a427e47f10 100644
1072c8
--- a/block/vhdx.c
1072c8
+++ b/block/vhdx.c
1072c8
@@ -411,8 +411,7 @@ int vhdx_update_headers(BlockDriverState *bs, BDRVVHDXState *s,
1072c8
     if (ret < 0) {
1072c8
         return ret;
1072c8
     }
1072c8
-    ret = vhdx_update_header(bs, s, generate_data_write_guid, log_guid);
1072c8
-    return ret;
1072c8
+    return vhdx_update_header(bs, s, generate_data_write_guid, log_guid);
1072c8
 }
1072c8
 
1072c8
 /* opens the specified header block from the VHDX file header section */
1072c8
diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
1072c8
index a136b97f68..a2cfae52b3 100644
1072c8
--- a/hw/audio/ac97.c
1072c8
+++ b/hw/audio/ac97.c
1072c8
@@ -574,11 +574,9 @@ static uint32_t nam_readb (void *opaque, uint32_t addr)
1072c8
 static uint32_t nam_readw (void *opaque, uint32_t addr)
1072c8
 {
1072c8
     AC97LinkState *s = opaque;
1072c8
-    uint32_t val = ~0U;
1072c8
     uint32_t index = addr;
1072c8
     s->cas = 0;
1072c8
-    val = mixer_load (s, index);
1072c8
-    return val;
1072c8
+    return mixer_load(s, index);
1072c8
 }
1072c8
 
1072c8
 static uint32_t nam_readl (void *opaque, uint32_t addr)
1072c8
diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c
1072c8
index cb4178d861..5779d09815 100644
1072c8
--- a/hw/audio/adlib.c
1072c8
+++ b/hw/audio/adlib.c
1072c8
@@ -120,13 +120,10 @@ static void adlib_write(void *opaque, uint32_t nport, uint32_t val)
1072c8
 static uint32_t adlib_read(void *opaque, uint32_t nport)
1072c8
 {
1072c8
     AdlibState *s = opaque;
1072c8
-    uint8_t data;
1072c8
     int a = nport & 3;
1072c8
 
1072c8
     adlib_kill_timers (s);
1072c8
-    data = OPLRead (s->opl, a);
1072c8
-
1072c8
-    return data;
1072c8
+    return OPLRead (s->opl, a);
1072c8
 }
1072c8
 
1072c8
 static void timer_handler (void *opaque, int c, double interval_Sec)
1072c8
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
1072c8
index 93afa26fda..a52d3094b9 100644
1072c8
--- a/hw/display/cirrus_vga.c
1072c8
+++ b/hw/display/cirrus_vga.c
1072c8
@@ -2411,12 +2411,10 @@ static uint64_t cirrus_linear_bitblt_read(void *opaque,
1072c8
                                           unsigned size)
1072c8
 {
1072c8
     CirrusVGAState *s = opaque;
1072c8
-    uint32_t ret;
1072c8
 
1072c8
     /* XXX handle bitblt */
1072c8
     (void)s;
1072c8
-    ret = 0xff;
1072c8
-    return ret;
1072c8
+    return 0xff;
1072c8
 }
1072c8
 
1072c8
 static void cirrus_linear_bitblt_write(void *opaque,
1072c8
diff --git a/migration/ram.c b/migration/ram.c
1072c8
index 5344c7d59e..92c506d13c 100644
1072c8
--- a/migration/ram.c
1072c8
+++ b/migration/ram.c
1072c8
@@ -3101,9 +3101,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *ms)
1072c8
     }
1072c8
     trace_ram_postcopy_send_discard_bitmap();
1072c8
 
1072c8
-    ret = postcopy_each_ram_send_discard(ms);
1072c8
-
1072c8
-    return ret;
1072c8
+    return postcopy_each_ram_send_discard(ms);
1072c8
 }
1072c8
 
1072c8
 /**
1072c8
diff --git a/ui/gtk.c b/ui/gtk.c
1072c8
index 692ccc7bbb..e032e3c36f 100644
1072c8
--- a/ui/gtk.c
1072c8
+++ b/ui/gtk.c
1072c8
@@ -1649,8 +1649,7 @@ static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc,
1072c8
                      G_CALLBACK(gd_menu_switch_vc), s);
1072c8
     gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item);
1072c8
 
1072c8
-    group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
1072c8
-    return group;
1072c8
+    return gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
1072c8
 }
1072c8
 
1072c8
 #if defined(CONFIG_VTE)
1072c8
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
1072c8
index bcc06d0e01..86c48b9fa5 100644
1072c8
--- a/util/qemu-sockets.c
1072c8
+++ b/util/qemu-sockets.c
1072c8
@@ -765,15 +765,12 @@ static int vsock_connect_addr(const struct sockaddr_vm *svm, Error **errp)
1072c8
 static int vsock_connect_saddr(VsockSocketAddress *vaddr, Error **errp)
1072c8
 {
1072c8
     struct sockaddr_vm svm;
1072c8
-    int sock = -1;
1072c8
 
1072c8
     if (!vsock_parse_vaddr_to_sockaddr(vaddr, &svm, errp)) {
1072c8
         return -1;
1072c8
     }
1072c8
 
1072c8
-    sock = vsock_connect_addr(&svm, errp);
1072c8
-
1072c8
-    return sock;
1072c8
+    return vsock_connect_addr(&svm, errp);
1072c8
 }
1072c8
 
1072c8
 static int vsock_listen_saddr(VsockSocketAddress *vaddr,
1072c8
-- 
1072c8
2.27.0
1072c8