mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
lib: use struct zero initializer instead of memset
This is a more concise approach and guarantees there is
no time window where the struct is uninitialized.
Generated using the following semantic patch:
@@
type T;
identifier X;
@@
- T X;
+ T X = { 0 };
... when exists
(
- memset(&X, 0, sizeof(X));
|
- memset(&X, 0, sizeof(T));
)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
This commit is contained in:
@@ -484,13 +484,12 @@ aiforaf(const char *name, int af, struct addrinfo *pai, struct addrinfo **aip)
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
} sa;
|
||||
} sa = { 0 };
|
||||
socklen_t salen;
|
||||
void *address = *addrList;
|
||||
char host[NI_MAXHOST];
|
||||
char port[NI_MAXSERV];
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
if (resolved.h_addrtype == AF_INET) {
|
||||
sa.sin.sin_family = AF_INET;
|
||||
memcpy(&sa.sin.sin_addr.s_addr,
|
||||
|
||||
Reference in New Issue
Block a user