From 59b5437eb732d6b103a9bc279c3482c834d1eff9 Mon Sep 17 00:00:00 2001 From: Alexey Kirillov Date: Wed, 3 Mar 2021 12:59:08 +0300 Subject: net: Move NetClientState.info_str to dynamic allocations The info_str field of the NetClientState structure is static and has a size of 256 bytes. This amount is often unclaimed, and the field itself is used exclusively for HMP "info network". The patch translates info_str to dynamic memory allocation. This action is also allows us to painlessly discard usage of this field for backend devices. Signed-off-by: Alexey Kirillov Signed-off-by: Jason Wang --- net/slirp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'net/slirp.c') diff --git a/net/slirp.c b/net/slirp.c index 6ab348b943..bfa07e3432 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -664,9 +664,8 @@ static int net_slirp_init(NetClientState *peer, const char *model, stored->tftp_server_name = g_strdup(tftp_server_name); } - snprintf(nc->info_str, sizeof(nc->info_str), - "net=%s,restrict=%s", inet_ntoa(net), - restricted ? "on" : "off"); + nc->info_str = g_strdup_printf("net=%s,restrict=%s", inet_ntoa(net), + restricted ? "on" : "off"); s = DO_UPCAST(SlirpState, nc, nc); -- cgit v1.2.3