Move memset() from net_client_uninit() to net_client_init()

zeroing a structure before using it is more common than zeroing after
using it. Also makes the setting of nd->used more obvious.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Mark McLoughlin 2009-10-06 12:16:54 +01:00 committed by Anthony Liguori
parent 9203f5202b
commit d2cffe303e
1 changed files with 2 additions and 1 deletions

3
net.c
View File

@ -2443,6 +2443,7 @@ int net_client_init(Monitor *mon, const char *device, const char *p)
goto out; goto out;
} }
nd = &nd_table[idx]; nd = &nd_table[idx];
memset(nd, 0, sizeof(*nd));
macaddr = nd->macaddr; macaddr = nd->macaddr;
macaddr[0] = 0x52; macaddr[0] = 0x52;
macaddr[1] = 0x54; macaddr[1] = 0x54;
@ -2818,7 +2819,7 @@ void net_client_uninit(NICInfo *nd)
qemu_free(nd->devaddr); qemu_free(nd->devaddr);
qemu_free(nd->id); qemu_free(nd->id);
memset(nd, 0, sizeof(*nd)); nd->used = 0;
} }
static int net_host_check_device(const char *device) static int net_host_check_device(const char *device)