All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 3/5] qobject: replace qobject_incref/QINCREF qobject_decref/QDECREF
Date: Thu, 19 Apr 2018 08:16:09 +0200	[thread overview]
Message-ID: <877ep3yb4m.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20180417133602.23832-4-marcandre.lureau@redhat.com> (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Tue, 17 Apr 2018 15:36:00 +0200")

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

> Now that we can safely call QOBJECT() on QObject * as well as its
> subtypes, we can have macros qobject_ref() / qobject_unref() that work
> everywhere instead of having to use QINCREF() / QDECREF() for QObject
> and qobject_incref() / qobject_decref() for its subtypes.
>
> Note that the new macros evaluate their argument exactly once, thus no
> need to shout them.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  scripts/qapi/events.py              |   2 +-
>  include/qapi/qmp/qnull.h            |   2 +-
>  include/qapi/qmp/qobject.h          |  36 +++++-----
[...]
>  tests/wdt_ib700-test.c              |  14 ++--
>  util/keyval.c                       |  12 ++--
>  util/qemu-config.c                  |   4 +-
>  docs/devel/qapi-code-gen.txt        |   2 +-
>  scripts/coccinelle/qobject.cocci    |   8 +--
>  94 files changed, 606 insertions(+), 610 deletions(-)

The patch is not entirely mechanical (evidence: Eric's observations).
How did you create it?

> diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py
> index 3dc523cf39..4426861ff1 100644
> --- a/scripts/qapi/events.py
> +++ b/scripts/qapi/events.py
> @@ -142,7 +142,7 @@ out:
>  ''')
>      ret += mcgen('''
>      error_propagate(errp, err);
> -    QDECREF(qmp);
> +    qobject_unref(qmp);
>  }
>  ''')
>      return ret
> diff --git a/include/qapi/qmp/qnull.h b/include/qapi/qmp/qnull.h
> index e8ea2c315a..75b29c6a39 100644
> --- a/include/qapi/qmp/qnull.h
> +++ b/include/qapi/qmp/qnull.h
> @@ -23,7 +23,7 @@ extern QNull qnull_;
>  
>  static inline QNull *qnull(void)
>  {
> -    QINCREF(&qnull_);
> +    qobject_ref(&qnull_);
>      return &qnull_;
>  }
>  
> diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
> index 0a7f800d58..e08fbb80b9 100644
> --- a/include/qapi/qmp/qobject.h
> +++ b/include/qapi/qmp/qobject.h
> @@ -16,16 +16,16 @@
>   *
>   *  - Returning references: A function that returns an object may
>   *  return it as either a weak or a strong reference.  If the reference
> - *  is strong, you are responsible for calling QDECREF() on the reference
> + *  is strong, you are responsible for calling qobject_unref() on the reference

Long line.

>   *  when you are done.
>   *
>   *  If the reference is weak, the owner of the reference may free it at
>   *  any time in the future.  Before storing the reference anywhere, you
> - *  should call QINCREF() to make the reference strong.
> + *  should call qobject_ref() to make the reference strong.
>   *
>   *  - Transferring ownership: when you transfer ownership of a reference
>   *  by calling a function, you are no longer responsible for calling
> - *  QDECREF() when the reference is no longer needed.  In other words,
> + *  qobject_unref() when the reference is no longer needed.  In other words,
>   *  when the function returns you must behave as if the reference to the
>   *  passed object was weak.
>   */
[...]

  parent reply	other threads:[~2018-04-19  6:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17 13:35 [Qemu-devel] [PATCH v5 0/5] Simplify qobject refcount Marc-André Lureau
2018-04-17 13:35 ` [Qemu-devel] [PATCH v5 1/5] qobject: ensure base is at offset 0 Marc-André Lureau
2018-04-17 18:17   ` Eric Blake
2018-04-18 16:45     ` Markus Armbruster
2018-04-18 16:58       ` Marc-André Lureau
2018-04-18 17:04       ` Eric Blake
2018-04-19  6:07         ` Markus Armbruster
2018-04-17 13:35 ` [Qemu-devel] [PATCH v5 2/5] qobject: use a QObjectBase_ struct Marc-André Lureau
2018-04-17 18:33   ` Eric Blake
2018-04-19  6:11   ` Markus Armbruster
2018-04-17 13:36 ` [Qemu-devel] [PATCH v5 3/5] qobject: replace qobject_incref/QINCREF qobject_decref/QDECREF Marc-André Lureau
2018-04-17 18:46   ` Eric Blake
2018-04-19  6:16   ` Markus Armbruster [this message]
2018-04-19 14:27     ` Marc-André Lureau
2018-04-17 13:36 ` [Qemu-devel] [PATCH v5 4/5] qobject: modify qobject_ref() to return obj Marc-André Lureau
2018-04-17 18:50   ` Eric Blake
2018-04-19  6:25     ` Markus Armbruster
2018-04-17 13:36 ` [Qemu-devel] [PATCH v5 5/5] qobject: modify qobject_ref() to assert on NULL Marc-André Lureau
2018-04-17 18:51   ` Eric Blake
2018-04-19  6:18   ` Markus Armbruster
2018-04-19 13:37     ` Marc-André Lureau
2018-04-19  6:44 ` [Qemu-devel] [PATCH v5 0/5] Simplify qobject refcount Markus Armbruster
2018-04-19 10:09   ` Marc-André Lureau
2018-04-19 11:48     ` Marc-André Lureau
2018-04-19 13:13       ` Markus Armbruster

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=877ep3yb4m.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=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.