mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
Use g_new() & friends where that makes obvious sense
g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Patch created mechanically with: $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocci \ --macro-file scripts/cocci-macro-file.h FILES... The previous iteration was commit a95942b50c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20220923084254.4173111-1-armbru@redhat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
76eb88b12b
commit
c5e8d51824
4 changed files with 6 additions and 6 deletions
|
@ -710,7 +710,7 @@ virtio_crypto_handle_asym_req(VirtIOCrypto *vcrypto,
|
|||
uint8_t *src = NULL;
|
||||
uint8_t *dst = NULL;
|
||||
|
||||
asym_op_info = g_malloc0(sizeof(CryptoDevBackendAsymOpInfo));
|
||||
asym_op_info = g_new0(CryptoDevBackendAsymOpInfo, 1);
|
||||
src_len = ldl_le_p(&req->para.src_data_len);
|
||||
dst_len = ldl_le_p(&req->para.dst_data_len);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue