Skip to contentSkip to conversation

Remove unused functions

PATCH Applied Thomas Huth 5 participants 13 messages Feb 19, 2015 – Mar 2, 2015

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Remove unused functions

There are quite a lot of completely unused functions scattered around in the QEMU sources - here are some patches to remove at least some of them.

v2:
- Incorporated review feedback to keep the functions that still might be usefull (e.g. dropped the patch to remove unused functions in the block layer)
- Added a patch to remove xen_cmos_set_s3_resume()

Thomas Huth (5):
migration: Remove unused functions
ui: Removed unused functions
ui/vnc: Remove vnc_stop_worker_thread()
util: Remove unused functions
xen: Remove xen_cmos_set_s3_resume()

 arch_init.c                   |   10 ------
 include/hw/xen/xen.h          |    1 -
 include/migration/migration.h |    3 --
 include/migration/qemu-file.h |    2 -
 include/qemu-common.h         |    4 --
 include/qemu/compatfd.h       |    1 -
 include/ui/console.h          |    3 --
 migration/migration.c         |    9 -----
 migration/qemu-file-buf.c     |   53 ---------------------------------
 ui/console.c                  |   12 -------
 ui/d3des.c                    |    9 -----
 ui/d3des.h                    |    6 ----
 ui/input-legacy.c             |    6 ----
 ui/vnc-jobs.c                 |   13 --------
 ui/vnc-jobs.h                 |    1 -
 util/compatfd.c               |   19 ------------
 util/osdep.c                  |   66 -----------------------------------------
 xen-hvm-stub.c                |    4 --
 18 files changed, 0 insertions(+), 222 deletions(-)
#1 lore raw

PATCH v2 1/5 migration: Remove unused functions

dup_mig_bytes_transferred(), skipped_mig_bytes_transferred(), migrate_rdma_pin_all(), qsb_clone() and qsb_set_length() are completely unused and thus can be deleted.

Cc Juan Quintela <[email protected]>
Cc Amit Shah <[email protected]>
---
 arch_init.c                   |   10 -------
 include/migration/migration.h |    3 --
 include/migration/qemu-file.h |    2 -
 migration/migration.c         |    9 -------
 migration/qemu-file-buf.c     |   53 -----------------------------------------
 5 files changed, 0 insertions(+), 77 deletions(-)
arch_init.c +0 -10
index 89c8fa4..ad5ce28 100644
@@ -249,21 +249,11 @@ static void acct_clear(void)
     memset(&acct_info, 0, sizeof(acct_info));
 }
 
-uint64_t dup_mig_bytes_transferred(void)
-{
-    return acct_info.dup_pages * TARGET_PAGE_SIZE;
-}
-
 uint64_t dup_mig_pages_transferred(void)
 {
     return acct_info.dup_pages;
 }
 
-uint64_t skipped_mig_bytes_transferred(void)
-{
-    return acct_info.skipped_pages * TARGET_PAGE_SIZE;
-}
-
 uint64_t skipped_mig_pages_transferred(void)
 {
     return acct_info.skipped_pages;
include/migration/migration.h +0 -3
index f37348b..7f6cdaa 100644
@@ -115,9 +115,7 @@ void free_xbzrle_decoded_buf(void);
 
 void acct_update_position(QEMUFile *f, size_t size, bool zero);
 
-uint64_t dup_mig_bytes_transferred(void);
 uint64_t dup_mig_pages_transferred(void);
-uint64_t skipped_mig_bytes_transferred(void);
 uint64_t skipped_mig_pages_transferred(void);
 uint64_t norm_mig_bytes_transferred(void);
 uint64_t norm_mig_pages_transferred(void);
@@ -143,7 +141,6 @@ void migrate_add_blocker(Error *reason);
  */
 void migrate_del_blocker(Error *reason);
 
-bool migrate_rdma_pin_all(void);
 bool migrate_zero_blocks(void);
 
 bool migrate_auto_converge(void);
include/migration/qemu-file.h +0 -2
index a923cec..45d7f71 100644
@@ -133,9 +133,7 @@ bool qemu_file_mode_is_not_valid(const char *mode);
 bool qemu_file_is_writable(QEMUFile *f);
 
 QEMUSizedBuffer *qsb_create(const uint8_t *buffer, size_t len);
-QEMUSizedBuffer *qsb_clone(const QEMUSizedBuffer *);
 void qsb_free(QEMUSizedBuffer *);
-size_t qsb_set_length(QEMUSizedBuffer *qsb, size_t length);
 size_t qsb_get_length(const QEMUSizedBuffer *qsb);
 ssize_t qsb_get_buffer(const QEMUSizedBuffer *, off_t start, size_t count,
                        uint8_t *buf);
migration/migration.c +0 -9
index b3adbc6..6f1a490 100644
@@ -540,15 +540,6 @@ void qmp_migrate_set_downtime(double value, Error **errp)
     max_downtime = (uint64_t)value;
 }
 
-bool migrate_rdma_pin_all(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL];
-}
-
 bool migrate_auto_converge(void)
 {
     MigrationState *s;
migration/qemu-file-buf.c +0 -53

65 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/5] migration: Remove unused functions

Quoted 27 lines · Thomas Huth

dup_mig_bytes_transferred(), skipped_mig_bytes_transferred(), migrate_rdma_pin_all(), qsb_clone() and qsb_set_length() are completely unused and thus can be deleted.

Cc Juan Quintela <[email protected]>
Cc Amit Shah <[email protected]>
---
 arch_init.c                   |   10 -------
 include/migration/migration.h |    3 --
 include/migration/qemu-file.h |    2 -
 migration/migration.c         |    9 -------
 migration/qemu-file-buf.c     |   53 -----------------------------------------
 5 files changed, 0 insertions(+), 77 deletions(-)
arch_init.c +0 -4
index 89c8fa4..ad5ce28 100644
@@ -249,21 +249,11 @@ static void acct_clear(void)
     memset(&acct_info, 0, sizeof(acct_info));
 }
 
-uint64_t dup_mig_bytes_transferred(void)
-{
-    return acct_info.dup_pages * TARGET_PAGE_SIZE;
-}

arch_init.c static void acct_clear(void) · line 265

Quoted 10 lines
arch_init.c +0 -5
-
 uint64_t dup_mig_pages_transferred(void)
 {
     return acct_info.dup_pages;
 }
 
-uint64_t skipped_mig_bytes_transferred(void)
-{
-    return acct_info.skipped_pages * TARGET_PAGE_SIZE;
-}

These could be used for reporting; Juan, any idea why these aren't used?

Rest of the patch is fine.

Amit

#3 lore raw

Re: [Qemu-devel] [PATCH 1/5] migration: Remove unused functions

Quoted 34 lines · On Tue, 24 Feb 2015 14:58:29 +0530 Amit Shah <[email protected]> wrote:
Quoted 33 lines · Thomas Huth

dup_mig_bytes_transferred(), skipped_mig_bytes_transferred(), migrate_rdma_pin_all(), qsb_clone() and qsb_set_length() are completely unused and thus can be deleted.

Cc Juan Quintela <[email protected]>
Cc Amit Shah <[email protected]>
---
 arch_init.c                   |   10 -------
 include/migration/migration.h |    3 --
 include/migration/qemu-file.h |    2 -
 migration/migration.c         |    9 -------
 migration/qemu-file-buf.c     |   53 -----------------------------------------
 5 files changed, 0 insertions(+), 77 deletions(-)
arch_init.c +0 -5
index 89c8fa4..ad5ce28 100644
@@ -249,21 +249,11 @@ static void acct_clear(void)
     memset(&acct_info, 0, sizeof(acct_info));
 }
 
-uint64_t dup_mig_bytes_transferred(void)
-{
-    return acct_info.dup_pages * TARGET_PAGE_SIZE;
-}
-
 uint64_t dup_mig_pages_transferred(void)
 {
     return acct_info.dup_pages;
 }
 
Quoted 7 lines

arch_init.c static void acct_clear(void) · line 265

Quoted 4 lines
arch_init.c +0 -4
-uint64_t skipped_mig_bytes_transferred(void)
-{
-    return acct_info.skipped_pages * TARGET_PAGE_SIZE;
-}

These could be used for reporting; Juan, any idea why these aren't used?

Since they are very trivial, I think they could easily be re-added again in case they are needed again in the future.
Or if you prefer, I can also rework my patch so that these two functions won't get deleted.

Thomas

#4 lore raw

Re: [Qemu-devel] [PATCH 1/5] migration: Remove unused functions

Quoted 45 lines · Thomas Huth
Quoted 34 lines · On Tue, 24 Feb 2015 14:58:29 +0530 Amit Shah <[email protected]> wrote:
Quoted 33 lines · Thomas Huth

dup_mig_bytes_transferred(), skipped_mig_bytes_transferred(), migrate_rdma_pin_all(), qsb_clone() and qsb_set_length() are completely unused and thus can be deleted.

Cc Juan Quintela <[email protected]>
Cc Amit Shah <[email protected]>
---
 arch_init.c                   |   10 -------
 include/migration/migration.h |    3 --
 include/migration/qemu-file.h |    2 -
 migration/migration.c         |    9 -------
 migration/qemu-file-buf.c     |   53 -----------------------------------------
 5 files changed, 0 insertions(+), 77 deletions(-)
arch_init.c +0 -5
index 89c8fa4..ad5ce28 100644
@@ -249,21 +249,11 @@ static void acct_clear(void)
     memset(&acct_info, 0, sizeof(acct_info));
 }
 
-uint64_t dup_mig_bytes_transferred(void)
-{
-    return acct_info.dup_pages * TARGET_PAGE_SIZE;
-}
-
 uint64_t dup_mig_pages_transferred(void)
 {
     return acct_info.dup_pages;
 }
 
Quoted 7 lines

arch_init.c static void acct_clear(void) · line 265

Quoted 4 lines
arch_init.c +0 -4
-uint64_t skipped_mig_bytes_transferred(void)
-{
-    return acct_info.skipped_pages * TARGET_PAGE_SIZE;
-}

These could be used for reporting; Juan, any idea why these aren't used?

Quoted 4 lines

Since they are very trivial, I think they could easily be re-added again in case they are needed again in the future.
Or if you prefer, I can also rework my patch so that these two functions won't get deleted.

I'm just asking Juan if he knows why these are around; I don't mind if we get rid of them, but good to get confirmation from Juan (else we needlessly end up churning code).

Amit

#5 lore raw

PATCH v2 2/5 ui: Removed unused functions

In reply to Thomas Huth

Remove qemu_console_displaystate(), qemu_remove_kbd_event_handler(), qemu_different_endianness_pixelformat() and cpkey(), since they are completely unused.

Cc Anthony Liguori <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 include/ui/console.h |    3 ---
 ui/console.c         |   12 ------------
 ui/d3des.c           |    9 ---------
 ui/d3des.h           |    6 ------
 ui/input-legacy.c    |    6 ------
 5 files changed, 0 insertions(+), 36 deletions(-)
include/ui/console.h +0 -3
index 8a4d671..7c3b5d4 100644
@@ -36,7 +36,6 @@ typedef struct QEMUPutLEDEntry QEMUPutLEDEntry;
 
 QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func,
                                             void *opaque);
-void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry);
 QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
                                                 void *opaque, int absolute,
                                                 const char *name);
@@ -194,7 +193,6 @@ DisplaySurface *qemu_create_displaysurface_guestmem(int width, int height,
                                                     pixman_format_code_t format,
                                                     int linesize,
                                                     uint64_t addr);
-PixelFormat qemu_different_endianness_pixelformat(int bpp);
 PixelFormat qemu_default_pixelformat(int bpp);
 
 DisplaySurface *qemu_create_displaysurface(int width, int height);
@@ -322,7 +320,6 @@ void qemu_console_resize(QemuConsole *con, int width, int height);
 void qemu_console_copy(QemuConsole *con, int src_x, int src_y,
                        int dst_x, int dst_y, int w, int h);
 DisplaySurface *qemu_console_surface(QemuConsole *con);
-DisplayState *qemu_console_displaystate(QemuConsole *console);
 
 /* sdl.c */
 void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
ui/console.c +0 -12
index 87574a7..87af6b5 100644
@@ -2005,18 +2005,6 @@ DisplaySurface *qemu_console_surface(QemuConsole *console)
     return console->surface;
 }
 
-DisplayState *qemu_console_displaystate(QemuConsole *console)
-{
-    return console->ds;
-}
-
-PixelFormat qemu_different_endianness_pixelformat(int bpp)
-{
-    pixman_format_code_t fmt = qemu_default_pixman_format(bpp, false);
-    PixelFormat pf = qemu_pixelformat_from_pixman(fmt);
-    return pf;
-}
-
 PixelFormat qemu_default_pixelformat(int bpp)
 {
     pixman_format_code_t fmt = qemu_default_pixman_format(bpp, true);
ui/d3des.c +0 -9
index 60c840e..5bc99b8 100644
@@ -121,15 +121,6 @@ static void cookey(register unsigned long *raw1)
 	return;
 	}
 
-void cpkey(register unsigned long *into)
-{
-	register unsigned long *from, *endp;
-
-	from = KnL, endp = &KnL[32];
-	while( from < endp ) *into++ = *from++;
-	return;
-	}
-
 void usekey(register unsigned long *from)
 {
 	register unsigned long *to, *endp;
ui/d3des.h +0 -6
index 70cb6b5..773667e 100644
@@ -36,12 +36,6 @@ void usekey(unsigned long *);
  * Loads the internal key register with the data in cookedkey.
  */
 
-void cpkey(unsigned long *);
-/*		   cookedkey[32]
- * Copies the contents of the internal key register into the storage
- * located at &cookedkey[0].
- */
-
 void des(unsigned char *, unsigned char *);
 /*		    from[8]	      to[8]
  * Encrypts/Decrypts (according to the key currently loaded in the
ui/input-legacy.c +0 -6
index a698a34..2d4ca19 100644
@@ -143,12 +143,6 @@ QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
     return entry;
 }
 
-void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry)
-{
-    qemu_input_handler_unregister(entry->s);
-    g_free(entry);
-}
-
 static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
                                InputEvent *evt)
 {
Signature · 1 line
1.7.1
Reviewed-by on v2 2/5
#6 lore raw

Re: [Qemu-devel] [PATCH 2/5] ui: Removed unused functions

Quoted 3 lines · Thomas Huth

Remove qemu_console_displaystate(), qemu_remove_kbd_event_handler(), qemu_different_endianness_pixelformat() and cpkey(), since they are completely unused.

#7 lore raw

PATCH v2 3/5 ui/vnc: Remove vnc_stop_worker_thread()

In reply to Thomas Huth

This function is not used anymore, let's remove it.

Cc Anthony Liguori <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 ui/vnc-jobs.c |   13 -------------
 ui/vnc-jobs.h |    1 -
 2 files changed, 0 insertions(+), 14 deletions(-)
ui/vnc-jobs.c +0 -13
index 68f3d77..c8ee203 100644
@@ -342,16 +342,3 @@ void vnc_start_worker_thread(void)
                        QEMU_THREAD_DETACHED);
     queue = q; /* Set global queue */
 }
-
-void vnc_stop_worker_thread(void)
-{
-    if (!vnc_worker_thread_running())
-        return ;
-
-    /* Remove all jobs and wake up the thread */
-    vnc_lock_queue(queue);
-    queue->exit = true;
-    vnc_unlock_queue(queue);
-    vnc_jobs_clear(NULL);
-    qemu_cond_broadcast(&queue->cond);
-}
ui/vnc-jobs.h +0 -1
index 31da103..044bf9f 100644
@@ -40,7 +40,6 @@ void vnc_jobs_join(VncState *vs);
 
 void vnc_jobs_consume_buffer(VncState *vs);
 void vnc_start_worker_thread(void);
-void vnc_stop_worker_thread(void);
 
 /* Locks */
 static inline int vnc_trylock_display(VncDisplay *vd)
Signature · 1 line
1.7.1
#9 lore raw

PATCH v2 4/5 util: Remove unused functions

In reply to Thomas Huth

Delete the unused functions qemu_signalfd_available(), qemu_send_full() and qemu_recv_full().

Cc Markus Armbruster <[email protected]>
---
 include/qemu-common.h   |    4 ---
 include/qemu/compatfd.h |    1 -
 util/compatfd.c         |   19 -------------
 util/osdep.c            |   66 -----------------------------------------------
 4 files changed, 0 insertions(+), 90 deletions(-)
include/qemu-common.h +0 -4
index 644b46d..0aac082 100644
@@ -217,10 +217,6 @@ void *qemu_oom_check(void *ptr);
 
 ssize_t qemu_write_full(int fd, const void *buf, size_t count)
     QEMU_WARN_UNUSED_RESULT;
-ssize_t qemu_send_full(int fd, const void *buf, size_t count, int flags)
-    QEMU_WARN_UNUSED_RESULT;
-ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags)
-    QEMU_WARN_UNUSED_RESULT;
 
 #ifndef _WIN32
 int qemu_pipe(int pipefd[2]);
include/qemu/compatfd.h +0 -1
index 6b04877..fc37915 100644
@@ -39,6 +39,5 @@ struct qemu_signalfd_siginfo {
 };
 
 int qemu_signalfd(const sigset_t *mask);
-bool qemu_signalfd_available(void);
 
 #endif
util/compatfd.c +0 -19
index 341ada6..e857150 100644
@@ -108,22 +108,3 @@ int qemu_signalfd(const sigset_t *mask)
 
     return qemu_signalfd_compat(mask);
 }
-
-bool qemu_signalfd_available(void)
-{
-#ifdef CONFIG_SIGNALFD
-    sigset_t mask;
-    int fd;
-    bool ok;
-    sigemptyset(&mask);
-    errno = 0;
-    fd = syscall(SYS_signalfd, -1, &mask, _NSIG / 8);
-    ok = (errno != ENOSYS);
-    if (fd >= 0) {
-        close(fd);
-    }
-    return ok;
-#else
-    return false;
-#endif
-}
util/osdep.c +0 -66

72 lines not on this page · raw message

Signature · 1 line
1.7.1
#10 lore raw

PATCH v2 5/5 xen: Remove xen_cmos_set_s3_resume()

In reply to Thomas Huth

The function is not used anymore, and thus can be deleted.

Cc Stefano Stabellini <[email protected]>
---
 include/hw/xen/xen.h |    1 -
 xen-hvm-stub.c       |    4 ----
 2 files changed, 0 insertions(+), 5 deletions(-)
include/hw/xen/xen.h +0 -1
index b0ed04c..4356af4 100644
@@ -32,7 +32,6 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
-void xen_cmos_set_s3_resume(void *opaque, int irq, int level);
 
 qemu_irq *xen_interrupt_controller_init(void);
 
xen-hvm-stub.c +0 -4
index 2d98696..46867d8 100644
@@ -30,10 +30,6 @@ void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
 {
 }
 
-void xen_cmos_set_s3_resume(void *opaque, int irq, int level)
-{
-}
-
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr)
 {
 }
Signature · 1 line
1.7.1
Acked-by on v2 5/5
#11 lore raw

Re: [Qemu-devel] [PATCH 5/5] xen: Remove xen_cmos_set_s3_resume()

Quoted 4 lines · Thomas Huth

The function is not used anymore, and thus can be deleted.

Cc Stefano Stabellini <[email protected]>
Quoted 34 lines
 include/hw/xen/xen.h |    1 -
 xen-hvm-stub.c       |    4 ----
 2 files changed, 0 insertions(+), 5 deletions(-)
include/hw/xen/xen.h +0 -1
index b0ed04c..4356af4 100644
@@ -32,7 +32,6 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
-void xen_cmos_set_s3_resume(void *opaque, int irq, int level);
 
 qemu_irq *xen_interrupt_controller_init(void);
 
xen-hvm-stub.c +0 -4
index 2d98696..46867d8 100644
@@ -30,10 +30,6 @@ void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
 {
 }
 
-void xen_cmos_set_s3_resume(void *opaque, int irq, int level)
-{
-}
-
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr)
 {
 }
Signature · 1 line
1.7.1
#12 lore raw
In reply to Thomas Huth
Quoted 3 lines · Thomas Huth

There are quite a lot of completely unused functions scattered around in the QEMU sources - here are some patches to remove at least some of them.

Applied series to -trivial, thank you!

/mjt