diff mbox

[for-1.2,v3,1/3] qlist: add qlist_size()

Message ID 1345056344-31849-1-git-send-email-mdroth@linux.vnet.ibm.com
State New
Headers show

Commit Message

Michael Roth Aug. 15, 2012, 6:45 p.m. UTC
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qlist.c |   13 +++++++++++++
 qlist.h |    1 +
 2 files changed, 14 insertions(+)

Comments

Eric Blake Aug. 15, 2012, 7:52 p.m. UTC | #1
On 08/15/2012 12:45 PM, Michael Roth wrote:
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  qlist.c |   13 +++++++++++++
>  qlist.h |    1 +
>  2 files changed, 14 insertions(+)

No cover-letter?

Reviewed-by: Eric Blake <eblake@redhat.com>
Michael Roth Aug. 15, 2012, 8:31 p.m. UTC | #2
On Wed, Aug 15, 2012 at 01:52:33PM -0600, Eric Blake wrote:
> On 08/15/2012 12:45 PM, Michael Roth wrote:
> > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > ---
> >  qlist.c |   13 +++++++++++++
> >  qlist.h |    1 +
> >  2 files changed, 14 insertions(+)
> 
> No cover-letter?

Started off as 1 patch with the explanation in the commit

> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
> -- 
> Eric Blake   eblake@redhat.com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
Luiz Capitulino Aug. 16, 2012, 1:40 p.m. UTC | #3
On Wed, 15 Aug 2012 13:45:42 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:

> 
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

I've applied this series to the qmp branch for 1.2. I'll run some tests and if
all goes alright will send a pull request shortly.

> ---
>  qlist.c |   13 +++++++++++++
>  qlist.h |    1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/qlist.c b/qlist.c
> index 88498b1..b48ec5b 100644
> --- a/qlist.c
> +++ b/qlist.c
> @@ -124,6 +124,19 @@ int qlist_empty(const QList *qlist)
>      return QTAILQ_EMPTY(&qlist->head);
>  }
>  
> +static void qlist_size_iter(QObject *obj, void *opaque)
> +{
> +    size_t *count = opaque;
> +    (*count)++;
> +}
> +
> +size_t qlist_size(const QList *qlist)
> +{
> +    size_t count = 0;
> +    qlist_iter(qlist, qlist_size_iter, &count);
> +    return count;
> +}
> +
>  /**
>   * qobject_to_qlist(): Convert a QObject into a QList
>   */
> diff --git a/qlist.h b/qlist.h
> index d426bd4..ae776f9 100644
> --- a/qlist.h
> +++ b/qlist.h
> @@ -49,6 +49,7 @@ void qlist_iter(const QList *qlist,
>  QObject *qlist_pop(QList *qlist);
>  QObject *qlist_peek(QList *qlist);
>  int qlist_empty(const QList *qlist);
> +size_t qlist_size(const QList *qlist);
>  QList *qobject_to_qlist(const QObject *obj);
>  
>  static inline const QListEntry *qlist_first(const QList *qlist)
Michael Roth Aug. 16, 2012, 7:23 p.m. UTC | #4
On Thu, Aug 16, 2012 at 10:40:05AM -0300, Luiz Capitulino wrote:
> On Wed, 15 Aug 2012 13:45:42 -0500
> Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> 
> > 
> > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> 
> I've applied this series to the qmp branch for 1.2. I'll run some tests and if
> all goes alright will send a pull request shortly.
> 

I just noticed via our fancy #qemu github bot that Anthony
applied these already, but I asked about and if you want to
test/submit through your queue it should all work out. So either
way.

Thanks!

> > ---
> >  qlist.c |   13 +++++++++++++
> >  qlist.h |    1 +
> >  2 files changed, 14 insertions(+)
> > 
> > diff --git a/qlist.c b/qlist.c
> > index 88498b1..b48ec5b 100644
> > --- a/qlist.c
> > +++ b/qlist.c
> > @@ -124,6 +124,19 @@ int qlist_empty(const QList *qlist)
> >      return QTAILQ_EMPTY(&qlist->head);
> >  }
> >  
> > +static void qlist_size_iter(QObject *obj, void *opaque)
> > +{
> > +    size_t *count = opaque;
> > +    (*count)++;
> > +}
> > +
> > +size_t qlist_size(const QList *qlist)
> > +{
> > +    size_t count = 0;
> > +    qlist_iter(qlist, qlist_size_iter, &count);
> > +    return count;
> > +}
> > +
> >  /**
> >   * qobject_to_qlist(): Convert a QObject into a QList
> >   */
> > diff --git a/qlist.h b/qlist.h
> > index d426bd4..ae776f9 100644
> > --- a/qlist.h
> > +++ b/qlist.h
> > @@ -49,6 +49,7 @@ void qlist_iter(const QList *qlist,
> >  QObject *qlist_pop(QList *qlist);
> >  QObject *qlist_peek(QList *qlist);
> >  int qlist_empty(const QList *qlist);
> > +size_t qlist_size(const QList *qlist);
> >  QList *qobject_to_qlist(const QObject *obj);
> >  
> >  static inline const QListEntry *qlist_first(const QList *qlist)
>
Luiz Capitulino Aug. 16, 2012, 7:29 p.m. UTC | #5
On Thu, 16 Aug 2012 14:23:40 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:

> On Thu, Aug 16, 2012 at 10:40:05AM -0300, Luiz Capitulino wrote:
> > On Wed, 15 Aug 2012 13:45:42 -0500
> > Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> > 
> > > 
> > > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > 
> > I've applied this series to the qmp branch for 1.2. I'll run some tests and if
> > all goes alright will send a pull request shortly.
> > 
> 
> I just noticed via our fancy #qemu github bot that Anthony
> applied these already, but I asked about and if you want to
> test/submit through your queue it should all work out. So either
> way.

I've already tested it, and worked fine here. Let it go through Anthony's
work flow then, saves me a pull request :)
diff mbox

Patch

diff --git a/qlist.c b/qlist.c
index 88498b1..b48ec5b 100644
--- a/qlist.c
+++ b/qlist.c
@@ -124,6 +124,19 @@  int qlist_empty(const QList *qlist)
     return QTAILQ_EMPTY(&qlist->head);
 }
 
+static void qlist_size_iter(QObject *obj, void *opaque)
+{
+    size_t *count = opaque;
+    (*count)++;
+}
+
+size_t qlist_size(const QList *qlist)
+{
+    size_t count = 0;
+    qlist_iter(qlist, qlist_size_iter, &count);
+    return count;
+}
+
 /**
  * qobject_to_qlist(): Convert a QObject into a QList
  */
diff --git a/qlist.h b/qlist.h
index d426bd4..ae776f9 100644
--- a/qlist.h
+++ b/qlist.h
@@ -49,6 +49,7 @@  void qlist_iter(const QList *qlist,
 QObject *qlist_pop(QList *qlist);
 QObject *qlist_peek(QList *qlist);
 int qlist_empty(const QList *qlist);
+size_t qlist_size(const QList *qlist);
 QList *qobject_to_qlist(const QObject *obj);
 
 static inline const QListEntry *qlist_first(const QList *qlist)