aboutsummaryrefslogtreecommitdiff
path: root/net/net.c
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2021-04-02 11:03:33 +0800
committerJason Wang <jasowang@redhat.com>2021-04-08 17:33:59 +0800
commit56e6f594bf47a0a543ff5e6d14701355fe99b098 (patch)
tree0b3ee5f7b43fde16795a00537796a87f0289d020 /net/net.c
parent603f2f7c6c8c747d0189936a74fb33e610ce7858 (diff)
Revert "net: Move NetClientState.info_str to dynamic allocations"
Several issues has been reported for query-netdev info series. Consider it's late in the rc, this reverts commit commit 59b5437eb732d6b103a9bc279c3482c834d1eff9. Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net/net.c')
-rw-r--r--net/net.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/net/net.c b/net/net.c
index 277da712eb..9a2a6ab155 100644
--- a/net/net.c
+++ b/net/net.c
@@ -129,12 +129,11 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr)
void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6])
{
- g_free(nc->info_str);
- nc->info_str = g_strdup_printf(
- "model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
- nc->model,
- macaddr[0], macaddr[1], macaddr[2],
- macaddr[3], macaddr[4], macaddr[5]);
+ snprintf(nc->info_str, sizeof(nc->info_str),
+ "model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+ nc->model,
+ macaddr[0], macaddr[1], macaddr[2],
+ macaddr[3], macaddr[4], macaddr[5]);
}
static int mac_table[256] = {0};
@@ -353,7 +352,6 @@ static void qemu_free_net_client(NetClientState *nc)
}
g_free(nc->name);
g_free(nc->model);
- g_free(nc->info_str);
qapi_free_NetdevInfo(nc->stored_config);
if (nc->destructor) {
nc->destructor(nc);
@@ -1228,7 +1226,7 @@ void print_net_client(Monitor *mon, NetClientState *nc)
monitor_printf(mon, "%s: index=%d,type=%s,%s\n", nc->name,
nc->queue_index,
NetClientDriver_str(nc->info->type),
- nc->info_str ? nc->info_str : "");
+ nc->info_str);
if (!QTAILQ_EMPTY(&nc->filters)) {
monitor_printf(mon, "filters:\n");
}