[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH 30/88] QEMU Guest Agent: use g_new() family of fun
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-trivial] [PATCH 30/88] QEMU Guest Agent: use g_new() family of functions |
Date: |
Fri, 6 Oct 2017 20:49:25 -0300 |
From: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
[PMD: added qga/commands-posix.c and qga/commands-win32.c]
---
qga/commands-posix.c | 20 ++++++++++----------
qga/commands-win32.c | 12 ++++++------
qga/commands.c | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index ab0c63d931..3a4deb6ae0 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -906,16 +906,16 @@ static void build_guest_fsinfo_for_real_device(char const
*syspath,
}
}
- pciaddr = g_malloc0(sizeof(*pciaddr));
+ pciaddr = g_new0(GuestPCIAddress, 1);
pciaddr->domain = pci[0];
pciaddr->bus = pci[1];
pciaddr->slot = pci[2];
pciaddr->function = pci[3];
- disk = g_malloc0(sizeof(*disk));
+ disk = g_new0(GuestDiskAddress, 1);
disk->pci_controller = pciaddr;
- list = g_malloc0(sizeof(*list));
+ list = g_new0(GuestDiskAddressList, 1);
list->value = disk;
if (strcmp(driver, "ata_piix") == 0) {
@@ -1380,7 +1380,7 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error
**errp)
return NULL;
}
- response = g_malloc0(sizeof(*response));
+ response = g_new0(GuestFilesystemTrimResponse, 1);
QTAILQ_FOREACH(mount, &mounts, next) {
result = g_malloc0(sizeof(*result));
@@ -1897,12 +1897,12 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error
**errp)
GuestLogicalProcessor *vcpu;
GuestLogicalProcessorList *entry;
- vcpu = g_malloc0(sizeof *vcpu);
+ vcpu = g_new0(GuestLogicalProcessor, 1);
vcpu->logical_id = current++;
vcpu->has_can_offline = true; /* lolspeak ftw */
transfer_vcpu(vcpu, true, &local_err);
- entry = g_malloc0(sizeof *entry);
+ entry = g_new0(GuestLogicalProcessorList, 1);
entry->value = vcpu;
*link = entry;
@@ -2267,13 +2267,13 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error
**errp)
continue;
}
- mem_blk = g_malloc0(sizeof *mem_blk);
+ mem_blk = g_new0(GuestMemoryBlock, 1);
/* The d_name is "memoryXXX", phys_index is block id, same as XXX */
mem_blk->phys_index = strtoul(&de->d_name[6], NULL, 10);
mem_blk->has_can_offline = true; /* lolspeak ftw */
transfer_memory_block(mem_blk, true, NULL, &local_err);
- entry = g_malloc0(sizeof *entry);
+ entry = g_new0(GuestMemoryBlockList, 1);
entry->value = mem_blk;
*link = entry;
@@ -2308,13 +2308,13 @@ qmp_guest_set_memory_blocks(GuestMemoryBlockList
*mem_blks, Error **errp)
GuestMemoryBlockResponseList *entry;
GuestMemoryBlock *current_mem_blk = mem_blks->value;
- result = g_malloc0(sizeof(*result));
+ result = g_new0(GuestMemoryBlockResponse, 1);
result->phys_index = current_mem_blk->phys_index;
transfer_memory_block(current_mem_blk, false, result, &local_err);
if (local_err) { /* should never happen */
goto err;
}
- entry = g_malloc0(sizeof *entry);
+ entry = g_new0(GuestMemoryBlockResponseList, 1);
entry->value = result;
*link = entry;
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 619dbd2bc2..908f110b8b 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -617,7 +617,7 @@ static GuestDiskAddressList *build_guest_disk_info(char
*guid, Error **errp)
goto out_close;
}
- disk = g_malloc0(sizeof(*disk));
+ disk = g_new0(GuestDiskAddress, 1);
disk->bus_type = find_bus_type(bus);
if (bus == BusTypeScsi || bus == BusTypeAta || bus == BusTypeRAID
#if (_WIN32_WINNT >= 0x0600)
@@ -641,7 +641,7 @@ static GuestDiskAddressList *build_guest_disk_info(char
*guid, Error **errp)
disk->pci_controller = NULL;
}
- list = g_malloc0(sizeof(*list));
+ list = g_new0(GuestDiskAddressList, 1);
list->value = disk;
list->next = NULL;
out_close:
@@ -694,7 +694,7 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid,
Error **errp)
}
fs_name[sizeof(fs_name) - 1] = 0;
- fs = g_malloc(sizeof(*fs));
+ fs = g_new(GuestFilesystemInfo, 1);
fs->name = g_strdup(guid);
if (len == 0) {
fs->mountpoint = g_strdup("System Reserved");
@@ -877,7 +877,7 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error
**errp)
continue;
}
- uc_path = g_malloc(sizeof(WCHAR) * char_count);
+ uc_path = g_new(WCHAR, char_count);
if (!GetVolumePathNamesForVolumeNameW(guid, uc_path, char_count,
&char_count) || !*uc_path) {
/* strange, but this condition could be faced even with size == 2
*/
@@ -1348,12 +1348,12 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error
**errp)
GuestLogicalProcessor *vcpu;
GuestLogicalProcessorList *entry;
- vcpu = g_malloc0(sizeof *vcpu);
+ vcpu = g_new0(GuestLogicalProcessor, 1);
vcpu->logical_id = current++;
vcpu->online = true;
vcpu->has_can_offline = true;
- entry = g_malloc0(sizeof *entry);
+ entry = g_new0(GuestLogicalProcessorList, 1);
entry->value = vcpu;
*link = entry;
diff --git a/qga/commands.c b/qga/commands.c
index ff89e805cf..d4c78ac935 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -239,7 +239,7 @@ static char **guest_exec_get_args(const strList *entry,
bool log)
str = g_malloc(str_size);
*str = 0;
- args = g_malloc(count * sizeof(char *));
+ args = g_new(char *, count);
for (it = entry; it != NULL; it = it->next) {
args[i++] = it->value;
pstrcat(str, str_size, it->value);
--
2.14.2
- Re: [Qemu-trivial] [PATCH 23/88] M68K: use g_new() family of functions, (continued)
- [Qemu-trivial] [PATCH 24/88] MIPS: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 25/88] OpenRISC: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 26/88] S390: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 28/88] disas: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 27/88] SH4: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 29/88] SPARC: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 30/88] QEMU Guest Agent: use g_new() family of functions,
Philippe Mathieu-Daudé <=
- [Qemu-trivial] [PATCH 32/88] QObject: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 31/88] QMP: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 33/88] qom: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 34/88] qapi: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 35/88] Record/replay: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 36/88] SLIRP: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06