diff mbox series

[v2,6/8] qlit: qlit_type() function

Message ID 20201116224143.1284278-7-ehabkost@redhat.com
State New
Headers show
Series qom: Use qlit to represent property defaults | expand

Commit Message

Eduardo Habkost Nov. 16, 2020, 10:41 p.m. UTC
Useful function where we need to check for the qlit type before
converting it to an actual QObject.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qapi/qmp/qlit.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Marc-André Lureau Nov. 17, 2020, 8:53 a.m. UTC | #1
On Tue, Nov 17, 2020 at 2:48 AM Eduardo Habkost <ehabkost@redhat.com> wrote:

> Useful function where we need to check for the qlit type before
> converting it to an actual QObject.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

---
>  include/qapi/qmp/qlit.h | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h
> index f9e356d31e..acddb80831 100644
> --- a/include/qapi/qmp/qlit.h
> +++ b/include/qapi/qmp/qlit.h
> @@ -59,4 +59,9 @@ bool qlit_equal_qobject(const QLitObject *lhs, const
> QObject *rhs);
>
>  QObject *qobject_from_qlit(const QLitObject *qlit);
>
> +static inline QType qlit_type(const QLitObject *qlit)
> +{
> +    return qlit->type;
> +}
> +
>  #endif /* QLIT_H */
> --
> 2.28.0
>
>
>
Markus Armbruster Nov. 19, 2020, 10:41 a.m. UTC | #2
Eduardo Habkost <ehabkost@redhat.com> writes:

> Useful function where we need to check for the qlit type before
> converting it to an actual QObject.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  include/qapi/qmp/qlit.h | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h
> index f9e356d31e..acddb80831 100644
> --- a/include/qapi/qmp/qlit.h
> +++ b/include/qapi/qmp/qlit.h
> @@ -59,4 +59,9 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs);
>  
>  QObject *qobject_from_qlit(const QLitObject *qlit);
>  
> +static inline QType qlit_type(const QLitObject *qlit)
> +{
> +    return qlit->type;
> +}
> +
>  #endif /* QLIT_H */

Hiding qlit->type behind a function makes sense only when the structure
of QLitObject is an implementation secret.  It don't think it is.
Eduardo Habkost Nov. 19, 2020, 5:56 p.m. UTC | #3
On Thu, Nov 19, 2020 at 11:41:05AM +0100, Markus Armbruster wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
> 
> > Useful function where we need to check for the qlit type before
> > converting it to an actual QObject.
> >
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  include/qapi/qmp/qlit.h | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h
> > index f9e356d31e..acddb80831 100644
> > --- a/include/qapi/qmp/qlit.h
> > +++ b/include/qapi/qmp/qlit.h
> > @@ -59,4 +59,9 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs);
> >  
> >  QObject *qobject_from_qlit(const QLitObject *qlit);
> >  
> > +static inline QType qlit_type(const QLitObject *qlit)
> > +{
> > +    return qlit->type;
> > +}
> > +
> >  #endif /* QLIT_H */
> 
> Hiding qlit->type behind a function makes sense only when the structure
> of QLitObject is an implementation secret.  It don't think it is.

I thought all QLitObject fields were considered private.  If they
are not, I can happily get rid of that function.
diff mbox series

Patch

diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h
index f9e356d31e..acddb80831 100644
--- a/include/qapi/qmp/qlit.h
+++ b/include/qapi/qmp/qlit.h
@@ -59,4 +59,9 @@  bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs);
 
 QObject *qobject_from_qlit(const QLitObject *qlit);
 
+static inline QType qlit_type(const QLitObject *qlit)
+{
+    return qlit->type;
+}
+
 #endif /* QLIT_H */