All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Markus Armbruster" <armbru@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH 1/8] qapi: make 'CompatPolicy' the first arg in compat_policy_input_ok
Date: Wed, 28 Oct 2026 13:35:56 +0000	[thread overview]
Message-ID: <20261028133603.1893289-2-berrange@redhat.com> (raw)
In-Reply-To: <20261028133603.1893289-1-berrange@redhat.com>

The typical API design pattern is for a method to be named after
the type of the first arg passed into the method. For the
compat_policy_input_ok method, this points towards 'CompatPolicy'
being the first arg, matching compat_policy_check_security.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 include/qapi/compat-policy.h |  4 ++--
 qapi/qapi-util.c             | 16 ++++++++--------
 qapi/qapi-visit-core.c       |  4 ++--
 qapi/qmp-dispatch.c          |  2 +-
 qapi/qobject-input-visitor.c |  2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/qapi/compat-policy.h b/include/qapi/compat-policy.h
index f5af2090692..df87d716439 100644
--- a/include/qapi/compat-policy.h
+++ b/include/qapi/compat-policy.h
@@ -18,8 +18,8 @@
 
 extern CompatPolicy compat_policy;
 
-bool compat_policy_input_ok(uint64_t features,
-                            const CompatPolicy *policy,
+bool compat_policy_input_ok(const CompatPolicy *policy,
+                            uint64_t features,
                             ErrorClass error_class,
                             const char *kind, const char *name,
                             Error **errp);
diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c
index 38b1cec7a41..93898f57a05 100644
--- a/qapi/qapi-util.c
+++ b/qapi/qapi-util.c
@@ -19,8 +19,8 @@
 
 CompatPolicy compat_policy;
 
-static bool compat_policy_input_ok1(const char *adjective,
-                                    CompatPolicyInput policy,
+static bool compat_policy_input_ok1(CompatPolicyInput policy,
+                                    const char *adjective,
                                     ErrorClass error_class,
                                     const char *kind, const char *name,
                                     Error **errp)
@@ -38,21 +38,21 @@ static bool compat_policy_input_ok1(const char *adjective,
     }
 }
 
-bool compat_policy_input_ok(uint64_t features,
-                            const CompatPolicy *policy,
+bool compat_policy_input_ok(const CompatPolicy *policy,
+                            uint64_t features,
                             ErrorClass error_class,
                             const char *kind, const char *name,
                             Error **errp)
 {
     if ((features & 1u << QAPI_DEPRECATED)
-        && !compat_policy_input_ok1("Deprecated",
-                                    policy->deprecated_input,
+        && !compat_policy_input_ok1(policy->deprecated_input,
+                                    "Deprecated",
                                     error_class, kind, name, errp)) {
         return false;
     }
     if ((features & (1u << QAPI_UNSTABLE))
-        && !compat_policy_input_ok1("Unstable",
-                                    policy->unstable_input,
+        && !compat_policy_input_ok1(policy->unstable_input,
+                                    "Unstable",
                                     error_class, kind, name, errp)) {
         return false;
     }
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 706c61e0260..66d57dd447a 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -410,8 +410,8 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj,
     }
 
     if (lookup->features
-        && !compat_policy_input_ok(lookup->features[value],
-                                   &v->compat_policy,
+        && !compat_policy_input_ok(&v->compat_policy,
+                                   lookup->features[value],
                                    ERROR_CLASS_GENERIC_ERROR,
                                    "value", enum_str, errp)) {
         return false;
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 965cad64998..f2fb8f7976c 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -185,7 +185,7 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *requ
                   "The command %s has not been found", command);
         goto out;
     }
-    if (!compat_policy_input_ok(cmd->features, &compat_policy,
+    if (!compat_policy_input_ok(&compat_policy, cmd->features,
                                 ERROR_CLASS_COMMAND_NOT_FOUND,
                                 "command", command, &err)) {
         goto out;
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index c52d36997df..17d91746d3a 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -667,7 +667,7 @@ static bool qobject_input_policy_reject(Visitor *v, const char *name,
                                         uint64_t features,
                                         Error **errp)
 {
-    return !compat_policy_input_ok(features, &v->compat_policy,
+    return !compat_policy_input_ok(&v->compat_policy, features,
                                    ERROR_CLASS_GENERIC_ERROR,
                                    "parameter", name, errp);
 }
-- 
2.56.0



  reply	other threads:[~2026-10-28 13:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 13:35 [PATCH 0/8] qapi: last minute improvements/changes to -compat insecure-types Daniel P. Berrangé
2026-10-28 13:35 ` Daniel P. Berrangé [this message]
2026-10-28 13:35 ` [PATCH 2/8] qapi: add 'warn' option to CompatPolicyInput Daniel P. Berrangé
2026-10-29  6:56   ` Markus Armbruster
2026-10-29 10:48     ` Daniel P. Berrangé
2026-10-28 13:35 ` [PATCH 3/8] qapi: rename 'insecure-types' to 'insecure-input' Daniel P. Berrangé
2026-10-28 13:35 ` [PATCH 4/8] qapi: drop CompatPolicySecurity and use CompatPolicyInput Daniel P. Berrangé
2026-10-29  6:15   ` Markus Armbruster
2026-10-29 10:48     ` Daniel P. Berrangé
2026-10-28 13:36 ` [PATCH 5/8] qapi: rename compat_policy_check_security method Daniel P. Berrangé
2026-10-28 13:36 ` [PATCH 6/8] qapi: reverse arg order in compat_policy_security_ok Daniel P. Berrangé
2026-10-28 13:36 ` [PATCH 7/8] qemu-options: document -compat insecure-input parameter Daniel P. Berrangé
2026-10-29  6:52   ` Markus Armbruster
2026-10-29 10:56     ` Daniel P. Berrangé
2026-10-29 14:13       ` Markus Armbruster
2026-10-29 14:44         ` Daniel P. Berrangé
2026-10-28 13:36 ` [PATCH 8/8] qapi: print a message before aborting for -compat violations Daniel P. Berrangé

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=20261028133603.1893289-2-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@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.