[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 01/11] block: Simplify QAPI_LIST_ADD
From: |
Eric Blake |
Subject: |
[PATCH v6 01/11] block: Simplify QAPI_LIST_ADD |
Date: |
Tue, 27 Oct 2020 00:05:46 -0500 |
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>
---
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
- [PATCH v6 00/11] Exposing backing-chain allocation over NBD, Eric Blake, 2020/10/27
- [PATCH v6 03/11] nbd: Utilize QAPI_CLONE for type conversion, Eric Blake, 2020/10/27
- [PATCH v6 02/11] qapi: Make QAPI_LIST_ADD() public, Eric Blake, 2020/10/27
- [PATCH v6 04/11] nbd: Update qapi to support exporting multiple bitmaps, Eric Blake, 2020/10/27
- [PATCH v6 05/11] nbd: Simplify qemu bitmap context name, Eric Blake, 2020/10/27
- [PATCH v6 06/11] nbd: Refactor counting of metadata contexts, Eric Blake, 2020/10/27
- [PATCH v6 01/11] block: Simplify QAPI_LIST_ADD,
Eric Blake <=
- [PATCH v6 07/11] nbd: Allow export of multiple bitmaps for one device, Eric Blake, 2020/10/27
- [PATCH v6 08/11] block: Return depth level during bdrv_is_allocated_above, Eric Blake, 2020/10/27
- [PATCH v6 10/11] nbd: Add 'qemu-nbd -A' to expose allocation depth, Eric Blake, 2020/10/27
- [PATCH v6 09/11] nbd: Add new qemu:allocation-depth metadata context, Eric Blake, 2020/10/27
- [PATCH v6 11/11] qapi: Use QAPI_LIST_ADD() where possible, Eric Blake, 2020/10/27