[Qemu-devel] [PATCH] authz: Use OBJECT_CHECK() on objects

Philippe Mathieu-Daudé posted 1 patch 6 years, 11 months ago
Test docker-clang@ubuntu passed
Test asan passed
Test docker-mingw@fedora passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190315171218.11676-1-philmd@redhat.com
Maintainers: "Daniel P. Berrangé" <berrange@redhat.com>
include/authz/base.h     | 4 ++--
include/authz/list.h     | 4 ++--
include/authz/listfile.h | 4 ++--
include/authz/pamacct.h  | 4 ++--
include/authz/simple.h   | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
[Qemu-devel] [PATCH] authz: Use OBJECT_CHECK() on objects
Posted by Philippe Mathieu-Daudé 6 years, 11 months ago
TYPE_QAUTHZ is an abstract object of type TYPE_OBJECT. All other
are children of TYPE_QAUTHZ, thus also objects.

Keep INTERFACE_CHECK() for interfaces, and use OBJECT_CHECK() on
objects.

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/authz/base.h     | 4 ++--
 include/authz/list.h     | 4 ++--
 include/authz/listfile.h | 4 ++--
 include/authz/pamacct.h  | 4 ++--
 include/authz/simple.h   | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/authz/base.h b/include/authz/base.h
index 77dcd54c4c..55ac9581ad 100644
--- a/include/authz/base.h
+++ b/include/authz/base.h
@@ -35,8 +35,8 @@
      OBJECT_GET_CLASS(QAuthZClass, (obj), \
                       TYPE_QAUTHZ)
 #define QAUTHZ(obj) \
-     INTERFACE_CHECK(QAuthZ, (obj), \
-                     TYPE_QAUTHZ)
+     OBJECT_CHECK(QAuthZ, (obj), \
+                  TYPE_QAUTHZ)
 
 typedef struct QAuthZ QAuthZ;
 typedef struct QAuthZClass QAuthZClass;
diff --git a/include/authz/list.h b/include/authz/list.h
index a7225a747c..138ae7047c 100644
--- a/include/authz/list.h
+++ b/include/authz/list.h
@@ -33,8 +33,8 @@
     OBJECT_GET_CLASS(QAuthZListClass, (obj),    \
                       TYPE_QAUTHZ_LIST)
 #define QAUTHZ_LIST(obj) \
-    INTERFACE_CHECK(QAuthZList, (obj),          \
-                    TYPE_QAUTHZ_LIST)
+    OBJECT_CHECK(QAuthZList, (obj), \
+                 TYPE_QAUTHZ_LIST)
 
 typedef struct QAuthZList QAuthZList;
 typedef struct QAuthZListClass QAuthZListClass;
diff --git a/include/authz/listfile.h b/include/authz/listfile.h
index bcc8d80743..ebbd5a4288 100644
--- a/include/authz/listfile.h
+++ b/include/authz/listfile.h
@@ -34,8 +34,8 @@
     OBJECT_GET_CLASS(QAuthZListFileClass, (obj),    \
                       TYPE_QAUTHZ_LIST_FILE)
 #define QAUTHZ_LIST_FILE(obj) \
-    INTERFACE_CHECK(QAuthZListFile, (obj),          \
-                    TYPE_QAUTHZ_LIST_FILE)
+    OBJECT_CHECK(QAuthZListFile, (obj), \
+                 TYPE_QAUTHZ_LIST_FILE)
 
 typedef struct QAuthZListFile QAuthZListFile;
 typedef struct QAuthZListFileClass QAuthZListFileClass;
diff --git a/include/authz/pamacct.h b/include/authz/pamacct.h
index 6e3046e528..cad5b11d47 100644
--- a/include/authz/pamacct.h
+++ b/include/authz/pamacct.h
@@ -33,8 +33,8 @@
      OBJECT_GET_CLASS(QAuthZPAMClass, (obj), \
                       TYPE_QAUTHZ_PAM)
 #define QAUTHZ_PAM(obj) \
-     INTERFACE_CHECK(QAuthZPAM, (obj), \
-                     TYPE_QAUTHZ_PAM)
+     OBJECT_CHECK(QAuthZPAM, (obj), \
+                  TYPE_QAUTHZ_PAM)
 
 typedef struct QAuthZPAM QAuthZPAM;
 typedef struct QAuthZPAMClass QAuthZPAMClass;
diff --git a/include/authz/simple.h b/include/authz/simple.h
index ef13958269..30b932dfeb 100644
--- a/include/authz/simple.h
+++ b/include/authz/simple.h
@@ -32,8 +32,8 @@
     OBJECT_GET_CLASS(QAuthZSimpleClass, (obj),    \
                       TYPE_QAUTHZ_SIMPLE)
 #define QAUTHZ_SIMPLE(obj) \
-    INTERFACE_CHECK(QAuthZSimple, (obj),          \
-                    TYPE_QAUTHZ_SIMPLE)
+    OBJECT_CHECK(QAuthZSimple, (obj), \
+                 TYPE_QAUTHZ_SIMPLE)
 
 typedef struct QAuthZSimple QAuthZSimple;
 typedef struct QAuthZSimpleClass QAuthZSimpleClass;
-- 
2.20.1


Re: [Qemu-devel] [PATCH] authz: Use OBJECT_CHECK() on objects
Posted by Daniel P. Berrangé 6 years, 11 months ago
On Fri, Mar 15, 2019 at 06:12:18PM +0100, Philippe Mathieu-Daudé wrote:
> TYPE_QAUTHZ is an abstract object of type TYPE_OBJECT. All other
> are children of TYPE_QAUTHZ, thus also objects.
> 
> Keep INTERFACE_CHECK() for interfaces, and use OBJECT_CHECK() on
> objects.

Hmm

  #define OBJECT_CHECK(type, obj, name) \
    ((type *)object_dynamic_cast_assert(OBJECT(obj), (name), \
                                        __FILE__, __LINE__, __func__))

  #define INTERFACE_CHECK(interface, obj, name) \
    ((interface *)object_dynamic_cast_assert(OBJECT((obj)), (name), \
                                             __FILE__, __LINE__, __func__))

/me now wonders why INTERFACE_CHECK needs to exist at all....


> 
> Reported-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  include/authz/base.h     | 4 ++--
>  include/authz/list.h     | 4 ++--
>  include/authz/listfile.h | 4 ++--
>  include/authz/pamacct.h  | 4 ++--
>  include/authz/simple.h   | 4 ++--
>  5 files changed, 10 insertions(+), 10 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH] authz: Use OBJECT_CHECK() on objects
Posted by Markus Armbruster 6 years, 11 months ago
Daniel P. Berrangé <berrange@redhat.com> writes:

> On Fri, Mar 15, 2019 at 06:12:18PM +0100, Philippe Mathieu-Daudé wrote:
>> TYPE_QAUTHZ is an abstract object of type TYPE_OBJECT. All other
>> are children of TYPE_QAUTHZ, thus also objects.
>> 
>> Keep INTERFACE_CHECK() for interfaces, and use OBJECT_CHECK() on
>> objects.
>
> Hmm
>
>   #define OBJECT_CHECK(type, obj, name) \
>     ((type *)object_dynamic_cast_assert(OBJECT(obj), (name), \
>                                         __FILE__, __LINE__, __func__))
>
>   #define INTERFACE_CHECK(interface, obj, name) \
>     ((interface *)object_dynamic_cast_assert(OBJECT((obj)), (name), \
>                                              __FILE__, __LINE__, __func__))
>
> /me now wonders why INTERFACE_CHECK needs to exist at all....

Valid question.  See

Subject: Issues around TYPE_INTERFACE
Date: Tue, 12 Mar 2019 11:50:54 +0100
Message-ID: <87h8c82woh.fsf@dusky.pond.sub.org>

[...]