Skip to contentSkip to conversation

Remove unused functions

PATCH Superseded Thomas Huth 4 participants 10 messages Feb 16, 2015 – Feb 17, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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.

Thomas Huth (4):
migration: Remove unused functions
ui/console: Removed unused functions
util: Remove unused functions
block: Remove unused functions

 arch_init.c                   |   10 ----
 block.c                       |   11 ----
 include/block/block.h         |    1 -
 include/block/nbd.h           |    1 -
 include/migration/migration.h |    3 -
 include/migration/qemu-file.h |    2 -
 include/qemu-common.h         |    4 --
 include/qemu/compatfd.h       |    1 -
 include/qemu/option.h         |    2 -
 include/ui/console.h          |   11 ----
 include/ui/input.h            |    1 -
 include/ui/qemu-pixman.h      |    3 -
 migration/migration.c         |    9 ----
 migration/qemu-file-buf.c     |   53 ---------------------
 nbd.c                         |    9 ----
 ui/console.c                  |  103 -----------------------------------------
 ui/d3des.c                    |    9 ----
 ui/d3des.h                    |    6 --
 ui/input-legacy.c             |    6 --
 ui/input.c                    |    7 ---
 ui/qemu-pixman.c              |   19 --------
 ui/vnc-jobs.c                 |   13 -----
 ui/vnc-jobs.h                 |    1 -
 util/compatfd.c               |   19 --------
 util/osdep.c                  |   66 --------------------------
 util/qemu-option.c            |    6 --
 26 files changed, 0 insertions(+), 376 deletions(-)
#1 lore raw

PATCH 1/4 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

PATCH 2/4 ui/console: Removed unused functions

In reply to Thomas Huth

Remove dpy_gfx_update_dirty(), qemu_console_get_head(), qemu_console_get_ui_info(), qemu_console_get_width(), qemu_console_get_height(), emu_console_displaystate(), qemu_different_endianness_pixelformat(), void cpkey(), qemu_pixman_linebuf_copy(), qemu_pixman_color(), emu_remove_kbd_event_handler() and vnc_stop_worker_thread() since they are completely unused.

Cc Anthony Liguori <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 include/ui/console.h     |   11 -----
 include/ui/input.h       |    1 -
 include/ui/qemu-pixman.h |    3 -
 ui/console.c             |  103 ----------------------------------------------
 ui/d3des.c               |    9 ----
 ui/d3des.h               |    6 ---
 ui/input-legacy.c        |    6 ---
 ui/input.c               |    7 ---
 ui/qemu-pixman.c         |   19 --------
 ui/vnc-jobs.c            |   13 ------
 ui/vnc-jobs.h            |    1 -
 11 files changed, 0 insertions(+), 179 deletions(-)
include/ui/console.h +0 -11
index 8a4d671..abba208 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);
@@ -233,10 +231,6 @@ void dpy_text_resize(QemuConsole *con, int w, int h);
 void dpy_mouse_set(QemuConsole *con, int x, int y, int on);
 void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor);
 bool dpy_cursor_define_supported(QemuConsole *con);
-void dpy_gfx_update_dirty(QemuConsole *con,
-                          MemoryRegion *address_space,
-                          uint64_t base,
-                          bool invalidate);
 bool dpy_gfx_check_format(QemuConsole *con,
                           pixman_format_code_t format);
 
@@ -310,10 +304,6 @@ bool qemu_console_is_visible(QemuConsole *con);
 bool qemu_console_is_graphic(QemuConsole *con);
 bool qemu_console_is_fixedsize(QemuConsole *con);
 int qemu_console_get_index(QemuConsole *con);
-uint32_t qemu_console_get_head(QemuConsole *con);
-QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con);
-int qemu_console_get_width(QemuConsole *con, int fallback);
-int qemu_console_get_height(QemuConsole *con, int fallback);
 
 void text_consoles_set_display(DisplayState *ds);
 void console_select(unsigned int index);
@@ -322,7 +312,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);
include/ui/input.h +0 -1
index 5d5ac00..d50ea9d 100644
@@ -27,7 +27,6 @@ struct QemuInputHandler {
 QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
                                                    QemuInputHandler *handler);
 void qemu_input_handler_activate(QemuInputHandlerState *s);
-void qemu_input_handler_deactivate(QemuInputHandlerState *s);
 void qemu_input_handler_unregister(QemuInputHandlerState *s);
 void qemu_input_handler_bind(QemuInputHandlerState *s,
                              const char *device_id, int head,
include/ui/qemu-pixman.h +0 -3
index 3dee576..29c575c 100644
@@ -44,13 +44,10 @@ pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format,
                                            int width);
 void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
                               int width, int x, int y);
-void qemu_pixman_linebuf_copy(pixman_image_t *fb, int width, int x, int y,
-                              pixman_image_t *linebuf);
 pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
                                           pixman_image_t *image);
 void qemu_pixman_image_unref(pixman_image_t *image);
 
-pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color);
 pixman_image_t *qemu_pixman_glyph_from_vgafont(int height, const uint8_t *font,
                                                unsigned int ch);
 void qemu_pixman_glyph_render(pixman_image_t *glyph,
ui/console.c +0 -103

121 lines not on this page · raw message

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)
 {
ui/input.c +0 -7
index 7ba99e5..50499a1 100644
@@ -61,13 +61,6 @@ void qemu_input_handler_activate(QemuInputHandlerState *s)
     qemu_input_check_mode_change();
 }
 
-void qemu_input_handler_deactivate(QemuInputHandlerState *s)
-{
-    QTAILQ_REMOVE(&handlers, s, node);
-    QTAILQ_INSERT_TAIL(&handlers, s, node);
-    qemu_input_check_mode_change();
-}
-
 void qemu_input_handler_unregister(QemuInputHandlerState *s)
 {
     QTAILQ_REMOVE(&handlers, s, node);
ui/qemu-pixman.c +0 -19
index 4116e15..6587c00 100644
@@ -168,14 +168,6 @@ void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
                            x, y, 0, 0, 0, 0, width, 1);
 }
 
-/* copy linebuf to framebuffer */
-void qemu_pixman_linebuf_copy(pixman_image_t *fb, int width, int x, int y,
-                              pixman_image_t *linebuf)
-{
-    pixman_image_composite(PIXMAN_OP_SRC, linebuf, NULL, fb,
-                           0, 0, 0, 0, x, y, width, 1);
-}
-
 pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
                                           pixman_image_t *image)
 {
@@ -197,17 +189,6 @@ void qemu_pixman_image_unref(pixman_image_t *image)
     pixman_image_unref(image);
 }
 
-pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color)
-{
-    pixman_color_t c;
-
-    c.red   = ((color & pf->rmask) >> pf->rshift) << (16 - pf->rbits);
-    c.green = ((color & pf->gmask) >> pf->gshift) << (16 - pf->gbits);
-    c.blue  = ((color & pf->bmask) >> pf->bshift) << (16 - pf->bbits);
-    c.alpha = ((color & pf->amask) >> pf->ashift) << (16 - pf->abits);
-    return c;
-}
-
 pixman_image_t *qemu_pixman_glyph_from_vgafont(int height, const uint8_t *font,
                                                unsigned int ch)
 {
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
#3 lore raw

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

Quoted 7 lines · Thomas Huth

Remove dpy_gfx_update_dirty(), qemu_console_get_head(), qemu_console_get_ui_info(), qemu_console_get_width(), qemu_console_get_height(), emu_console_displaystate(), qemu_different_endianness_pixelformat(), void cpkey(), qemu_pixman_linebuf_copy(), qemu_pixman_color(), emu_remove_kbd_event_handler() and vnc_stop_worker_thread() since they are completely unused.

Vetoing this one. Some of them belong to work-in-progress bits and should not be removed.

Also I think this kind of cleanup should be splitted into smaller pieces, so it is easier to get specific bits back via "git revert" should the need arise.

Quoted 1 line

-void dpy_gfx_update_dirty(QemuConsole *con,

Keep.

Quoted 1 line

-QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con)

Keep.

ui/console.c int qemu_console_get_index(QemuConsole *con) · line 1821

Quoted 2 lines
ui/console.c +0 -2
-int qemu_console_get_width(QemuConsole *con, int fallback)
-int qemu_console_get_height(QemuConsole *con, int fallback)

Hmm, not sure. Separate patch please.

Quoted 1 line

-DisplayState *qemu_console_displaystate(QemuConsole *console)

Ok.

Quoted 1 line

-PixelFormat qemu_different_endianness_pixelformat(int bpp)

Ok.

Quoted 1 line

-void cpkey(register unsigned long *into)

Ok.

Quoted 1 line

-void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry)

Ok.

Quoted 1 line

-void qemu_input_handler_deactivate(QemuInputHandlerState *s)

Hmm, might be needed in the future. Separate patch please.

ui/qemu-pixman.c void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb, · line 177

Quoted 7 lines
ui/qemu-pixman.c +0 -7
-/* copy linebuf to framebuffer */
-void qemu_pixman_linebuf_copy(pixman_image_t *fb, int width, int x, int y,
-                              pixman_image_t *linebuf)
-{
-    pixman_image_composite(PIXMAN_OP_SRC, linebuf, NULL, fb,
-                           0, 0, 0, 0, x, y, width, 1);
-}

Keep.

ui/qemu-pixman.c void qemu_pixman_image_unref(pixman_image_t *image) · line 209

Quoted 10 lines
ui/qemu-pixman.c +0 -10
-pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color)
-{
-    pixman_color_t c;
-
-    c.red   = ((color & pf->rmask) >> pf->rshift) << (16 - pf->rbits);
-    c.green = ((color & pf->gmask) >> pf->gshift) << (16 - pf->gbits);
-    c.blue  = ((color & pf->bmask) >> pf->bshift) << (16 - pf->bbits);
-    c.alpha = ((color & pf->amask) >> pf->ashift) << (16 - pf->abits);
-    return c;
-}

Not sure. Separate patch please.

Quoted 1 line

-void vnc_stop_worker_thread(void)

Probably ok. Separate patch would be nice.

cheers,
Gerd

#4 lore raw

PATCH 3/4 util: Remove unused functions

In reply to Thomas Huth

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

---
 include/qemu-common.h   |    4 ---
 include/qemu/compatfd.h |    1 -
 include/qemu/option.h   |    2 -
 util/compatfd.c         |   19 -------------
 util/osdep.c            |   66 -----------------------------------------------
 util/qemu-option.c      |    6 ----
 6 files changed, 0 insertions(+), 98 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
include/qemu/option.h +0 -2
index 58c0157..9fdec02 100644
@@ -89,8 +89,6 @@ bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval);
 uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval);
 uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval);
 bool qemu_opt_get_bool_del(QemuOpts *opts, const char *name, bool defval);
-uint64_t qemu_opt_get_number_del(QemuOpts *opts, const char *name,
-                                 uint64_t defval);
 uint64_t qemu_opt_get_size_del(QemuOpts *opts, const char *name,
                                uint64_t defval);
 int qemu_opt_unset(QemuOpts *opts, const char *name);
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

util/qemu-option.c +0 -6
index d3ab65d..0e408eb 100644
@@ -433,12 +433,6 @@ uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval)
     return qemu_opt_get_number_helper(opts, name, defval, false);
 }
 
-uint64_t qemu_opt_get_number_del(QemuOpts *opts, const char *name,
-                                 uint64_t defval)
-{
-    return qemu_opt_get_number_helper(opts, name, defval, true);
-}
-
 static uint64_t qemu_opt_get_size_helper(QemuOpts *opts, const char *name,
                                          uint64_t defval, bool del)
 {
Signature · 1 line
1.7.1
#5 lore raw

Re: [Qemu-devel] [PATCH 3/4] util: Remove unused functions

Quoted 4 lines · Thomas Huth

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

qemu_opt_get_number_del() was added in commit 782730b along with qemu_opt_get_del(), qemu_opt_get_bool_del() and qemu_opt_get_size_del(). It hasn't been used so far, but removing it makes the interface irregular. I'd rather not. Covering all four in tests/test-qemu-opts.c would be nice.

qemu_send_full() and qemu_recv_full() complement qemu_write_full(). On the other hand, there's no qemu_read_full(). I don't think keeping the two unused ones hurts, but I don't object to dropping them, either.

For what it's worth, glibc provides a macro to solve this problem once and for all:

    /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
       set to EINTR.  */

    # define TEMP_FAILURE_RETRY(expression) \
      (__extension__                                        \
        ({ long int __result;                               \
           do __result = (long int) (expression);           \
           while (__result == -1L && errno == EINTR);       \
           __result; }))
    #endif

More elegant than writing the same old boring wrapper around everything that can fail with EINTR.

qemu_signalfd_available() is unused since commit 6d32717. It's also the only user of CONFIG_SIGNALFD. If we want to drop it, I recommend dropping CONFIG_SIGNALFD as well.

#6 lore raw

Re: [Qemu-devel] [PATCH 3/4] util: Remove unused functions

Hi,

Quoted 11 lines · On Tue, 17 Feb 2015 09:55:33 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 4 lines · Thomas Huth

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

qemu_opt_get_number_del() was added in commit 782730b along with qemu_opt_get_del(), qemu_opt_get_bool_del() and qemu_opt_get_size_del(). It hasn't been used so far, but removing it makes the interface irregular. I'd rather not.

Ok, then let's keep them.

Quoted 3 lines

qemu_signalfd_available() is unused since commit 6d32717. It's also the only user of CONFIG_SIGNALFD. If we want to drop it, I recommend dropping CONFIG_SIGNALFD as well.

As far as I can see, CONFIG_SIGNALFD is still used in qemu_signalfd(), so I think we've got to keep that.

Thomas

#7 lore raw

PATCH 4/4 block: Remove unused functions

In reply to Thomas Huth

qemu_try_blockalign0() and nbd_export_close_all() are not used anymore and thus can be removed.

Cc Kevin Wolf <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 block.c               |   11 -----------
 include/block/block.h |    1 -
 include/block/nbd.h   |    1 -
 nbd.c                 |    9 ---------
 4 files changed, 0 insertions(+), 22 deletions(-)
block.c +0 -11
index 210fd5f..2128f82 100644
@@ -5335,17 +5335,6 @@ void *qemu_try_blockalign(BlockDriverState *bs, size_t size)
     return qemu_try_memalign(align, size);
 }
 
-void *qemu_try_blockalign0(BlockDriverState *bs, size_t size)
-{
-    void *mem = qemu_try_blockalign(bs, size);
-
-    if (mem) {
-        memset(mem, 0, size);
-    }
-
-    return mem;
-}
-
 /*
  * Check if all memory in this vector is sector aligned.
  */
include/block/block.h +0 -1
index 321295e..7ee9ab3 100644
@@ -433,7 +433,6 @@ void bdrv_set_guest_block_size(BlockDriverState *bs, int align);
 void *qemu_blockalign(BlockDriverState *bs, size_t size);
 void *qemu_blockalign0(BlockDriverState *bs, size_t size);
 void *qemu_try_blockalign(BlockDriverState *bs, size_t size);
-void *qemu_try_blockalign0(BlockDriverState *bs, size_t size);
 bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov);
 
 struct HBitmapIter;
include/block/nbd.h +0 -1
index b759595..fccef2d 100644
@@ -95,7 +95,6 @@ BlockBackend *nbd_export_get_blockdev(NBDExport *exp);
 
 NBDExport *nbd_export_find(const char *name);
 void nbd_export_set_name(NBDExport *exp, const char *name);
-void nbd_export_close_all(void);
 
 NBDClient *nbd_client_new(NBDExport *exp, int csock,
                           void (*close)(NBDClient *));
nbd.c +0 -9
index e56afbc..634bf84 100644
@@ -1067,15 +1067,6 @@ BlockBackend *nbd_export_get_blockdev(NBDExport *exp)
     return exp->blk;
 }
 
-void nbd_export_close_all(void)
-{
-    NBDExport *exp, *next;
-
-    QTAILQ_FOREACH_SAFE(exp, &exports, next, next) {
-        nbd_export_close(exp);
-    }
-}
-
 static ssize_t nbd_co_send_reply(NBDRequest *req, struct nbd_reply *reply,
                                  int len)
 {
Signature · 1 line
1.7.1
#8 lore raw

Re: [Qemu-devel] [PATCH 4/4] block: Remove unused functions

Quoted 7 lines · Thomas Huth

qemu_try_blockalign0() and nbd_export_close_all() are not used anymore and thus can be removed.

Cc Kevin Wolf <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Paolo Bonzini <[email protected]>
Quoted 6 lines
---
  block.c               |   11 -----------
  include/block/block.h |    1 -
  include/block/nbd.h   |    1 -
  nbd.c                 |    9 ---------
  4 files changed, 0 insertions(+), 22 deletions(-)

NACK, I'm using nbd_export_close_all() in my "block: Rework bdrv_close_all()" series.

I'm not so sure about qemu_try_blockalign0(); it has never been used, but I introduced it because we have qemu_blockalign(), qemu_try_blockalign(), and qemu_blockalign0() (the latter of which I introduced along with qemu_try_blockalign0(), and this function is used).

So I'd be fine with removing qemu_try_blockalign0() again, but I don't really see the point in doing so. It is not a function that is per-se deprecated or something, quite the opposite, actually. If people can make use of that function, they should most certainly do so.

Max

Quoted 66 lines
block.c +0 -11
index 210fd5f..2128f82 100644
@@ -5335,17 +5335,6 @@ void *qemu_try_blockalign(BlockDriverState *bs, size_t size)
      return qemu_try_memalign(align, size);
  }
 
-void *qemu_try_blockalign0(BlockDriverState *bs, size_t size)
-{
-    void *mem = qemu_try_blockalign(bs, size);
-
-    if (mem) {
-        memset(mem, 0, size);
-    }
-
-    return mem;
-}
-
  /*
   * Check if all memory in this vector is sector aligned.
   */
include/block/block.h +0 -1
index 321295e..7ee9ab3 100644
@@ -433,7 +433,6 @@ void bdrv_set_guest_block_size(BlockDriverState *bs, int align);
  void *qemu_blockalign(BlockDriverState *bs, size_t size);
  void *qemu_blockalign0(BlockDriverState *bs, size_t size);
  void *qemu_try_blockalign(BlockDriverState *bs, size_t size);
-void *qemu_try_blockalign0(BlockDriverState *bs, size_t size);
  bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov);
 
  struct HBitmapIter;
include/block/nbd.h +0 -1
index b759595..fccef2d 100644
@@ -95,7 +95,6 @@ BlockBackend *nbd_export_get_blockdev(NBDExport *exp);
 
  NBDExport *nbd_export_find(const char *name);
  void nbd_export_set_name(NBDExport *exp, const char *name);
-void nbd_export_close_all(void);
 
  NBDClient *nbd_client_new(NBDExport *exp, int csock,
                            void (*close)(NBDClient *));
nbd.c +0 -9
index e56afbc..634bf84 100644
@@ -1067,15 +1067,6 @@ BlockBackend *nbd_export_get_blockdev(NBDExport *exp)
      return exp->blk;
  }
 
-void nbd_export_close_all(void)
-{
-    NBDExport *exp, *next;
-
-    QTAILQ_FOREACH_SAFE(exp, &exports, next, next) {
-        nbd_export_close(exp);
-    }
-}
-
  static ssize_t nbd_co_send_reply(NBDRequest *req, struct nbd_reply *reply,
                                   int len)
  {
#9 lore raw

Re: [Qemu-devel] [PATCH 4/4] block: Remove unused functions

Hi Max,

Quoted 15 lines · On Mon, 16 Feb 2015 17:26:56 -0500 Max Reitz <[email protected]> wrote:
Quoted 7 lines · Thomas Huth

qemu_try_blockalign0() and nbd_export_close_all() are not used anymore and thus can be removed.

Cc Kevin Wolf <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Paolo Bonzini <[email protected]>
Quoted 6 lines
---
  block.c               |   11 -----------
  include/block/block.h |    1 -
  include/block/nbd.h   |    1 -
  nbd.c                 |    9 ---------
  4 files changed, 0 insertions(+), 22 deletions(-)
Quoted 2 lines

NACK, I'm using nbd_export_close_all() in my "block: Rework bdrv_close_all()" series.

Alright, if it's going to be used again, then it must not be removed, of course.

Quoted 9 lines

I'm not so sure about qemu_try_blockalign0(); it has never been used, but I introduced it because we have qemu_blockalign(), qemu_try_blockalign(), and qemu_blockalign0() (the latter of which I introduced along with qemu_try_blockalign0(), and this function is used).

So I'd be fine with removing qemu_try_blockalign0() again, but I don't really see the point in doing so. It is not a function that is per-se deprecated or something, quite the opposite, actually. If people can make use of that function, they should most certainly do so.

I'm not a big fan of providing unused (and likely untested) functions just because they could be used somewhen in a distant future (unless they are part of a proper library) ... I'd rather add such functions again when they are really being used.

Anyway, this is just a small, trivial function, and if you prefer to keep it, then please ignore this patch simply completely. There is certainly no urgent need for removing unused functions, I just wanted to make people aware that there are some.

Thomas