qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	Markus Armbruster <armbru@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>,
	Max Reitz <mreitz@redhat.com>
Subject: [PULL 03/12] block: Simplify QAPI_LIST_ADD
Date: Tue, 27 Oct 2020 16:59:05 -0500	[thread overview]
Message-ID: <20201027215914.619460-4-eblake@redhat.com> (raw)
In-Reply-To: <20201027215914.619460-1-eblake@redhat.com>

There is no need to rely on the verbosity of the gcc/clang compiler
extension of g_new(typeof(X), 1) when we can instead use the standard
g_malloc(sizeof(X)).  In general, we like g_new over g_malloc for
returning type X rather than void* to let the compiler catch more
potential typing mistakes, but in this particular macro, our other use
of typeof on the same line already ensures we are getting correct
results.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20201027050556.269064-2-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block.c b/block.c
index 430edf79bb10..857387f3912f 100644
--- a/block.c
+++ b/block.c
@@ -5231,7 +5231,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(bool flat,
 }

 #define QAPI_LIST_ADD(list, element) do { \
-    typeof(list) _tmp = g_new(typeof(*(list)), 1); \
+    typeof(list) _tmp = g_malloc(sizeof(*(list))); \
     _tmp->value = (element); \
     _tmp->next = (list); \
     (list) = _tmp; \
-- 
2.29.0



  parent reply	other threads:[~2020-10-27 22:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 21:59 [PULL 00/12] NBD patches for 2020-10-27 soft-freeze Eric Blake
2020-10-27 21:59 ` [PULL 01/12] iotests/291: Filter irrelevant parts of img-info Eric Blake
2020-10-27 21:59 ` [PULL 02/12] iotests/291: Stop NBD server Eric Blake
2020-10-27 21:59 ` Eric Blake [this message]
2020-10-27 21:59 ` [PULL 04/12] qapi: Add QAPI_LIST_PREPEND() macro Eric Blake
2020-10-27 21:59 ` [PULL 05/12] nbd: Utilize QAPI_CLONE for type conversion Eric Blake
2020-10-27 21:59 ` [PULL 06/12] nbd: Update qapi to support exporting multiple bitmaps Eric Blake
2020-10-27 21:59 ` [PULL 07/12] nbd: Simplify qemu bitmap context name Eric Blake
2020-10-27 21:59 ` [PULL 08/12] nbd: Refactor counting of metadata contexts Eric Blake
2020-10-27 21:59 ` [PULL 09/12] nbd: Allow export of multiple bitmaps for one device Eric Blake
2020-10-27 21:59 ` [PULL 10/12] block: Return depth level during bdrv_is_allocated_above Eric Blake
2020-10-27 21:59 ` [PULL 11/12] nbd: Add new qemu:allocation-depth metadata context Eric Blake
2020-10-27 21:59 ` [PULL 12/12] nbd: Add 'qemu-nbd -A' to expose allocation depth Eric Blake
2020-10-30 20:17 ` [PULL 00/12] NBD patches for 2020-10-27 soft-freeze Eric Blake

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=20201027215914.619460-4-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).