diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/net.c | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -1213,10 +1213,9 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, Error **errp) { NetClientState *nc; - RxFilterInfoList *filter_list = NULL, *last_entry = NULL; + RxFilterInfoList *filter_list = NULL, **tail = &filter_list; QTAILQ_FOREACH(nc, &net_clients, next) { - RxFilterInfoList *entry; RxFilterInfo *info; if (has_name && strcmp(nc->name, name) != 0) { @@ -1227,6 +1226,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, if (nc->info->type != NET_CLIENT_DRIVER_NIC) { if (has_name) { error_setg(errp, "net client(%s) isn't a NIC", name); + assert(!filter_list); return NULL; } continue; @@ -1240,18 +1240,11 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, if (nc->info->query_rx_filter) { info = nc->info->query_rx_filter(nc); - entry = g_malloc0(sizeof(*entry)); - entry->value = info; - - if (!filter_list) { - filter_list = entry; - } else { - last_entry->next = entry; - } - last_entry = entry; + QAPI_LIST_APPEND(tail, info); } else if (has_name) { error_setg(errp, "net client(%s) doesn't support" " rx-filter querying", name); + assert(!filter_list); return NULL; } |