All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 38/40] qemu-option: remove now-dead code
Date: Tue,  6 Jul 2021 12:01:39 +0200	[thread overview]
Message-ID: <20210706100141.303960-39-pbonzini@redhat.com> (raw)
In-Reply-To: <20210706100141.303960-1-pbonzini@redhat.com>

-M was the sole user of qemu_opts_set and qemu_opts_set_defaults,
remove them and the arguments that they used.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/option.h       |  3 ---
 tests/unit/test-qemu-opts.c | 35 -------------------------
 util/qemu-option.c          | 51 ++++++++-----------------------------
 3 files changed, 10 insertions(+), 79 deletions(-)

diff --git a/include/qemu/option.h b/include/qemu/option.h
index fffb03d848..306bf07575 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -119,7 +119,6 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
                            int fail_if_exists, Error **errp);
 void qemu_opts_reset(QemuOptsList *list);
 void qemu_opts_loc_restore(QemuOpts *opts);
-bool qemu_opts_set(QemuOptsList *list, const char *name, const char *value, Error **errp);
 const char *qemu_opts_id(QemuOpts *opts);
 void qemu_opts_set_id(QemuOpts *opts, char *id);
 void qemu_opts_del(QemuOpts *opts);
@@ -130,8 +129,6 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
                                   bool permit_abbrev);
 QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
                           bool permit_abbrev, Error **errp);
-void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
-                            int permit_abbrev);
 QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
                                Error **errp);
 QDict *qemu_opts_to_qdict_filtered(QemuOpts *opts, QDict *qdict,
diff --git a/tests/unit/test-qemu-opts.c b/tests/unit/test-qemu-opts.c
index 6568e31a72..828d40e928 100644
--- a/tests/unit/test-qemu-opts.c
+++ b/tests/unit/test-qemu-opts.c
@@ -410,40 +410,6 @@ static void test_qemu_opts_reset(void)
     g_assert(opts == NULL);
 }
 
-static void test_qemu_opts_set(void)
-{
-    QemuOptsList *list;
-    QemuOpts *opts;
-    const char *opt;
-
-    list = qemu_find_opts("opts_list_04");
-    g_assert(list != NULL);
-    g_assert(QTAILQ_EMPTY(&list->head));
-    g_assert_cmpstr(list->name, ==, "opts_list_04");
-
-    /* should not find anything at this point */
-    opts = qemu_opts_find(list, NULL);
-    g_assert(opts == NULL);
-
-    /* implicitly create opts and set str3 value */
-    qemu_opts_set(list, "str3", "value", &error_abort);
-    g_assert(!QTAILQ_EMPTY(&list->head));
-
-    /* get the just created opts */
-    opts = qemu_opts_find(list, NULL);
-    g_assert(opts != NULL);
-
-    /* check the str3 value */
-    opt = qemu_opt_get(opts, "str3");
-    g_assert_cmpstr(opt, ==, "value");
-
-    qemu_opts_del(opts);
-
-    /* should not find anything at this point */
-    opts = qemu_opts_find(list, NULL);
-    g_assert(opts == NULL);
-}
-
 static int opts_count_iter(void *opaque, const char *name, const char *value,
                            Error **errp)
 {
@@ -1041,7 +1007,6 @@ int main(int argc, char *argv[])
     g_test_add_func("/qemu-opts/opt_get_size", test_qemu_opt_get_size);
     g_test_add_func("/qemu-opts/opt_unset", test_qemu_opt_unset);
     g_test_add_func("/qemu-opts/opts_reset", test_qemu_opts_reset);
-    g_test_add_func("/qemu-opts/opts_set", test_qemu_opts_set);
     g_test_add_func("/qemu-opts/opts_parse/general", test_opts_parse);
     g_test_add_func("/qemu-opts/opts_parse/bool", test_opts_parse_bool);
     g_test_add_func("/qemu-opts/opts_parse/number", test_opts_parse_number);
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 4944015a25..ee78e42216 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -479,19 +479,14 @@ int qemu_opt_unset(QemuOpts *opts, const char *name)
     }
 }
 
-static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value,
-                           bool prepend)
+static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value)
 {
     QemuOpt *opt = g_malloc0(sizeof(*opt));
 
     opt->name = g_strdup(name);
     opt->str = value;
     opt->opts = opts;
-    if (prepend) {
-        QTAILQ_INSERT_HEAD(&opts->head, opt, next);
-    } else {
-        QTAILQ_INSERT_TAIL(&opts->head, opt, next);
-    }
+    QTAILQ_INSERT_TAIL(&opts->head, opt, next);
 
     return opt;
 }
@@ -518,7 +513,7 @@ static bool opt_validate(QemuOpt *opt, Error **errp)
 bool qemu_opt_set(QemuOpts *opts, const char *name, const char *value,
                   Error **errp)
 {
-    QemuOpt *opt = opt_create(opts, name, g_strdup(value), false);
+    QemuOpt *opt = opt_create(opts, name, g_strdup(value));
 
     if (!opt_validate(opt, errp)) {
         qemu_opt_del(opt);
@@ -662,15 +657,6 @@ void qemu_opts_loc_restore(QemuOpts *opts)
     loc_restore(&opts->loc);
 }
 
-bool qemu_opts_set(QemuOptsList *list, const char *name, const char *value, Error **errp)
-{
-    QemuOpts *opts;
-
-    assert(list->merge_lists);
-    opts = qemu_opts_create(list, NULL, 0, &error_abort);
-    return qemu_opt_set(opts, name, value, errp);
-}
-
 const char *qemu_opts_id(QemuOpts *opts)
 {
     return opts->id;
@@ -811,7 +797,7 @@ static const char *get_opt_name_value(const char *params,
 }
 
 static bool opts_do_parse(QemuOpts *opts, const char *params,
-                          const char *firstname, bool prepend,
+                          const char *firstname,
                           bool warn_on_flag, bool *help_wanted, Error **errp)
 {
     char *option, *value;
@@ -833,7 +819,7 @@ static bool opts_do_parse(QemuOpts *opts, const char *params,
             continue;
         }
 
-        opt = opt_create(opts, option, value, prepend);
+        opt = opt_create(opts, option, value);
         g_free(option);
         if (!opt_validate(opt, errp)) {
             qemu_opt_del(opt);
@@ -889,11 +875,11 @@ bool has_help_option(const char *params)
 bool qemu_opts_do_parse(QemuOpts *opts, const char *params,
                        const char *firstname, Error **errp)
 {
-    return opts_do_parse(opts, params, firstname, false, false, NULL, errp);
+    return opts_do_parse(opts, params, firstname, false, NULL, errp);
 }
 
 static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
-                            bool permit_abbrev, bool defaults,
+                            bool permit_abbrev,
                             bool warn_on_flag, bool *help_wanted, Error **errp)
 {
     const char *firstname;
@@ -903,21 +889,13 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
     assert(!permit_abbrev || list->implied_opt_name);
     firstname = permit_abbrev ? list->implied_opt_name : NULL;
 
-    /*
-     * This code doesn't work for defaults && !list->merge_lists: when
-     * params has no id=, and list has an element with !opts->id, it
-     * appends a new element instead of returning the existing opts.
-     * However, we got no use for this case.  Guard against possible
-     * (if unlikely) future misuse:
-     */
-    assert(!defaults || list->merge_lists);
     opts = qemu_opts_create(list, id, !list->merge_lists, errp);
     g_free(id);
     if (opts == NULL) {
         return NULL;
     }
 
-    if (!opts_do_parse(opts, params, firstname, defaults,
+    if (!opts_do_parse(opts, params, firstname,
                        warn_on_flag, help_wanted, errp)) {
         qemu_opts_del(opts);
         return NULL;
@@ -936,7 +914,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
 QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
                           bool permit_abbrev, Error **errp)
 {
-    return opts_parse(list, params, permit_abbrev, false, false, NULL, errp);
+    return opts_parse(list, params, permit_abbrev, false, NULL, errp);
 }
 
 /**
@@ -954,7 +932,7 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
     QemuOpts *opts;
     bool help_wanted = false;
 
-    opts = opts_parse(list, params, permit_abbrev, false, true,
+    opts = opts_parse(list, params, permit_abbrev, true,
                       opts_accepts_any(list) ? NULL : &help_wanted,
                       &err);
     if (!opts) {
@@ -968,15 +946,6 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
     return opts;
 }
 
-void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
-                            int permit_abbrev)
-{
-    QemuOpts *opts;
-
-    opts = opts_parse(list, params, permit_abbrev, true, false, NULL, NULL);
-    assert(opts);
-}
-
 static bool qemu_opts_from_qdict_entry(QemuOpts *opts,
                                        const QDictEntry *entry,
                                        Error **errp)
-- 
2.31.1




  parent reply	other threads:[~2021-07-06 10:35 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 10:01 [PULL 00/40] Misc patches for 2021-07-06 Paolo Bonzini
2021-07-06 10:01 ` [PULL 01/40] Makefile: Remove /usr/bin/env wrapper from the SHELL variable Paolo Bonzini
2021-07-06 10:01 ` [PULL 02/40] softmmu/vl: Remove obsolete comment about the "frame" parameter Paolo Bonzini
2021-07-06 10:01 ` [PULL 03/40] ui: Fix the "-display sdl,window_close=..." parameter Paolo Bonzini
2021-07-06 10:01 ` [PULL 04/40] ui: Mark the '-no-quit' option as deprecated Paolo Bonzini
2021-07-06 10:01 ` [PULL 05/40] qemu-options: Improve the documentation of the -display options Paolo Bonzini
2021-07-06 10:01 ` [PULL 06/40] coverity-scan: Remove lm32 / unicore32 targets Paolo Bonzini
2021-07-06 10:01 ` [PULL 07/40] coverity-scan: switch to vpath build Paolo Bonzini
2021-07-06 10:01 ` [PULL 08/40] target/i386: Declare constants for XSAVE offsets Paolo Bonzini
2021-07-06 10:01 ` [PULL 09/40] target/i386: Consolidate the X86XSaveArea offset checks Paolo Bonzini
2021-07-06 10:01 ` [PULL 10/40] target/i386: Clarify the padding requirements of X86XSaveArea Paolo Bonzini
2021-07-06 10:01 ` [PULL 11/40] target/i386: Pass buffer and length to XSAVE helper Paolo Bonzini
2021-07-06 10:01 ` [PULL 12/40] target/i386: Make x86_ext_save_areas visible outside cpu.c Paolo Bonzini
2021-07-06 10:01 ` [PULL 13/40] target/i386: Observe XSAVE state area offsets Paolo Bonzini
2021-07-06 10:01 ` [PULL 14/40] target/i386: Populate x86_ext_save_areas offsets using cpuid where possible Paolo Bonzini
2021-07-06 10:01 ` [PULL 15/40] target/i386: Move X86XSaveArea into TCG Paolo Bonzini
2021-07-06 10:01 ` [PULL 16/40] configure: drop vte-2.90 check Paolo Bonzini
2021-07-06 10:01 ` [PULL 17/40] configure, meson: convert vte detection to meson Paolo Bonzini
2021-07-06 10:01 ` [PULL 18/40] configure, meson: convert virgl " Paolo Bonzini
2021-07-06 10:01 ` [PULL 19/40] configure, meson: convert libdaxctl " Paolo Bonzini
2021-07-06 10:01 ` [PULL 20/40] configure, meson: convert libpmem " Paolo Bonzini
2021-07-06 10:01 ` [PULL 21/40] configure, meson: convert liburing " Paolo Bonzini
2021-07-06 10:01 ` [PULL 22/40] configure, meson: convert libxml2 " Paolo Bonzini
2021-07-06 10:01 ` [PULL 23/40] meson: sort existing compiler tests Paolo Bonzini
2021-07-06 10:01 ` [PULL 24/40] meson: store dependency('threads') in a variable Paolo Bonzini
2021-07-06 10:01 ` [PULL 25/40] configure, meson: move CONFIG_IVSHMEM to meson Paolo Bonzini
2021-07-06 10:01 ` [PULL 26/40] configure: convert HAVE_BROKEN_SIZE_MAX " Paolo Bonzini
2021-07-06 10:01 ` [PULL 27/40] configure: convert compiler tests to meson, part 1 Paolo Bonzini
2021-07-06 10:01 ` [PULL 28/40] configure: convert compiler tests to meson, part 2 Paolo Bonzini
2021-07-06 10:01 ` [PULL 29/40] configure: convert compiler tests to meson, part 3 Paolo Bonzini
2021-07-06 10:01 ` [PULL 30/40] configure: convert compiler tests to meson, part 4 Paolo Bonzini
2021-07-06 10:01 ` [PULL 31/40] configure: convert compiler tests to meson, part 5 Paolo Bonzini
2021-07-06 10:01 ` [PULL 32/40] configure: convert compiler tests to meson, part 6 Paolo Bonzini
2021-07-06 10:01 ` [PULL 33/40] qom: export more functions for use with non-UserCreatable objects Paolo Bonzini
2021-07-06 10:01 ` [PULL 34/40] keyval: introduce keyval_merge Paolo Bonzini
2021-07-06 10:01 ` [PULL 35/40] keyval: introduce keyval_parse_into Paolo Bonzini
2021-07-06 10:01 ` [PULL 36/40] vl: switch -M parsing to keyval Paolo Bonzini
2021-07-08 16:31   ` Jason Andryuk
2021-07-08 16:31     ` Jason Andryuk
2021-07-13  2:15     ` [PATCH] vl: Parse legacy default_machine_opts Jason Andryuk
2021-07-22 14:12       ` Anthony PERARD via
2021-07-22 14:12         ` Anthony PERARD
2021-07-22 14:39         ` Paolo Bonzini
2021-07-22 14:39           ` Paolo Bonzini
2021-07-12 19:24   ` [PULL 36/40] vl: switch -M parsing to keyval Volker Rümelin
2021-07-13 19:43   ` Alex Williamson
2021-07-13 23:10     ` Alex Williamson
2021-07-14  6:16       ` Mark Cave-Ayland
2021-07-14 22:13         ` Alex Williamson
2021-07-22  8:19   ` Peter Krempa
2021-07-22 14:39     ` Paolo Bonzini
2021-07-22 14:50       ` Peter Krempa
2021-07-06 10:01 ` [PULL 37/40] machine: add smp compound property Paolo Bonzini
2021-07-13 10:37   ` Peter Maydell
2021-07-13 11:07     ` Markus Armbruster
2021-07-13 10:53   ` Peter Maydell
2021-07-06 10:01 ` Paolo Bonzini [this message]
2021-07-06 10:01 ` [PULL 39/40] Set icon for QEMU binary on Mac OS Paolo Bonzini
2021-07-06 10:01 ` [PULL 40/40] config-host.mak: remove unused compiler-related lines Paolo Bonzini
2021-07-06 12:10 ` [PULL 00/40] Misc patches for 2021-07-06 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210706100141.303960-39-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.