mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
Replace non-portable asprintf by g_strdup_printf
g_strdup_printf already handles OOM errors, so some error handling in QEMU code can be removed. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
0e7a759293
commit
e4ada48242
3 changed files with 9 additions and 17 deletions
|
@ -939,14 +939,11 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
|
|||
|
||||
mac_addr = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
|
||||
|
||||
if (asprintf(&info->value->hardware_address,
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
(int) mac_addr[0], (int) mac_addr[1],
|
||||
(int) mac_addr[2], (int) mac_addr[3],
|
||||
(int) mac_addr[4], (int) mac_addr[5]) == -1) {
|
||||
error_setg_errno(errp, errno, "failed to format MAC");
|
||||
goto error;
|
||||
}
|
||||
info->value->hardware_address =
|
||||
g_strdup_printf("%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
(int) mac_addr[0], (int) mac_addr[1],
|
||||
(int) mac_addr[2], (int) mac_addr[3],
|
||||
(int) mac_addr[4], (int) mac_addr[5]);
|
||||
|
||||
info->value->has_hardware_address = true;
|
||||
close(sock);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue