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:
Michal Privoznik 2023-08-02 10:09:52 +02:00
parent 7ce0fbccf1
commit b20a5e9a4d
65 changed files with 195 additions and 483 deletions

View File

@ -468,7 +468,7 @@ virCHMonitorBuildVMJson(virDomainDef *vmdef,
static int static int
chMonitorCreateSocket(const char *socket_path) chMonitorCreateSocket(const char *socket_path)
{ {
struct sockaddr_un addr; struct sockaddr_un addr = { 0 };
socklen_t addrlen = sizeof(addr); socklen_t addrlen = sizeof(addr);
int fd; int fd;
@ -478,7 +478,6 @@ chMonitorCreateSocket(const char *socket_path)
goto error; goto error;
} }
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
if (virStrcpyStatic(addr.sun_path, socket_path) < 0) { if (virStrcpyStatic(addr.sun_path, socket_path) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,

View File

@ -28859,9 +28859,7 @@ int
virDomainGraphicsListenAppendAddress(virDomainGraphicsDef *def, virDomainGraphicsListenAppendAddress(virDomainGraphicsDef *def,
const char *address) const char *address)
{ {
virDomainGraphicsListenDef glisten; virDomainGraphicsListenDef glisten = { 0 };
memset(&glisten, 0, sizeof(glisten));
glisten.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; glisten.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
@ -28877,9 +28875,7 @@ int
virDomainGraphicsListenAppendSocket(virDomainGraphicsDef *def, virDomainGraphicsListenAppendSocket(virDomainGraphicsDef *def,
const char *socketPath) const char *socketPath)
{ {
virDomainGraphicsListenDef glisten; virDomainGraphicsListenDef glisten = { 0 };
memset(&glisten, 0, sizeof(glisten));
glisten.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; glisten.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;

View File

@ -2748,11 +2748,9 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDef *def,
size_t i; size_t i;
int ret = -1; int ret = -1;
virNetworkIPDef *ipdef = virNetworkIPDefByIndex(def, parentIndex); virNetworkIPDef *ipdef = virNetworkIPDefByIndex(def, parentIndex);
virNetworkDHCPHostDef host; virNetworkDHCPHostDef host = { 0 };
bool partialOkay = (command == VIR_NETWORK_UPDATE_COMMAND_DELETE); bool partialOkay = (command == VIR_NETWORK_UPDATE_COMMAND_DELETE);
memset(&host, 0, sizeof(host));
if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "host") < 0) if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "host") < 0)
goto cleanup; goto cleanup;
@ -2881,9 +2879,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDef *def,
{ {
size_t i; size_t i;
virNetworkIPDef *ipdef = virNetworkIPDefByIndex(def, parentIndex); virNetworkIPDef *ipdef = virNetworkIPDefByIndex(def, parentIndex);
virNetworkDHCPRangeDef range; virNetworkDHCPRangeDef range = { 0 };
memset(&range, 0, sizeof(range));
if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "range") < 0) if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "range") < 0)
return -1; return -1;
@ -2990,9 +2986,7 @@ virNetworkDefUpdateForwardInterface(virNetworkDef *def,
{ {
size_t i; size_t i;
int ret = -1; int ret = -1;
virNetworkForwardIfDef iface; virNetworkForwardIfDef iface = { 0 };
memset(&iface, 0, sizeof(iface));
if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "interface") < 0) if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "interface") < 0)
goto cleanup; goto cleanup;
@ -3094,9 +3088,7 @@ virNetworkDefUpdatePortGroup(virNetworkDef *def,
size_t i; size_t i;
int foundName = -1, foundDefault = -1; int foundName = -1, foundDefault = -1;
int ret = -1; int ret = -1;
virPortGroupDef portgroup; virPortGroupDef portgroup = { 0 };
memset(&portgroup, 0, sizeof(portgroup));
if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "portgroup") < 0) if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "portgroup") < 0)
goto cleanup; goto cleanup;
@ -3184,13 +3176,11 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def,
size_t i, j, k; size_t i, j, k;
int foundIdx = -1, ret = -1; int foundIdx = -1, ret = -1;
virNetworkDNSDef *dns = &def->dns; virNetworkDNSDef *dns = &def->dns;
virNetworkDNSHostDef host; virNetworkDNSHostDef host = { 0 };
bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST || bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST ||
command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST); command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST);
int foundCt = 0; int foundCt = 0;
memset(&host, 0, sizeof(host));
if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) { if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("DNS HOST records cannot be modified, " _("DNS HOST records cannot be modified, "
@ -3283,13 +3273,11 @@ virNetworkDefUpdateDNSSrv(virNetworkDef *def,
size_t i; size_t i;
int foundIdx = -1, ret = -1; int foundIdx = -1, ret = -1;
virNetworkDNSDef *dns = &def->dns; virNetworkDNSDef *dns = &def->dns;
virNetworkDNSSrvDef srv; virNetworkDNSSrvDef srv = { 0 };
bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST || bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST ||
command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST); command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST);
int foundCt = 0; int foundCt = 0;
memset(&srv, 0, sizeof(srv));
if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) { if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("DNS SRV records cannot be modified, " _("DNS SRV records cannot be modified, "
@ -3368,12 +3356,10 @@ virNetworkDefUpdateDNSTxt(virNetworkDef *def,
{ {
int foundIdx, ret = -1; int foundIdx, ret = -1;
virNetworkDNSDef *dns = &def->dns; virNetworkDNSDef *dns = &def->dns;
virNetworkDNSTxtDef txt; virNetworkDNSTxtDef txt = { 0 };
bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST || bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST ||
command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST); command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST);
memset(&txt, 0, sizeof(txt));
if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) { if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("DNS TXT records cannot be modified, " _("DNS TXT records cannot be modified, "

View File

@ -1073,9 +1073,7 @@ static int
x86ParseMSR(xmlNodePtr node, x86ParseMSR(xmlNodePtr node,
virCPUx86DataItem *item) virCPUx86DataItem *item)
{ {
virCPUx86MSR msr; virCPUx86MSR msr = { 0 };
memset(&msr, 0, sizeof(msr));
if (virXMLPropUInt(node, "index", 0, VIR_XML_PROP_REQUIRED, &msr.index) < 0) if (virXMLPropUInt(node, "index", 0, VIR_XML_PROP_REQUIRED, &msr.index) < 0)
return -1; return -1;

View File

@ -2536,14 +2536,12 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
g_autofree char *url = NULL; g_autofree char *url = NULL;
g_autofree char *vmx = NULL; g_autofree char *vmx = NULL;
virVMXContext ctx; virVMXContext ctx;
esxVMX_Data data; esxVMX_Data data = { 0 };
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
char *xml = NULL; char *xml = NULL;
virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL); virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL);
memset(&data, 0, sizeof(data));
if (esxVI_EnsureSession(priv->primary) < 0) if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
@ -2622,14 +2620,12 @@ esxConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
{ {
esxPrivate *priv = conn->privateData; esxPrivate *priv = conn->privateData;
virVMXContext ctx; virVMXContext ctx;
esxVMX_Data data; esxVMX_Data data = { 0 };
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
char *xml = NULL; char *xml = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&data, 0, sizeof(data));
if (STRNEQ(nativeFormat, VMX_CONFIG_FORMAT_ARGV)) { if (STRNEQ(nativeFormat, VMX_CONFIG_FORMAT_ARGV)) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("Unsupported config format '%1$s'"), nativeFormat); _("Unsupported config format '%1$s'"), nativeFormat);
@ -2665,14 +2661,12 @@ esxConnectDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
esxPrivate *priv = conn->privateData; esxPrivate *priv = conn->privateData;
int virtualHW_version; int virtualHW_version;
virVMXContext ctx; virVMXContext ctx;
esxVMX_Data data; esxVMX_Data data = { 0 };
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
char *vmx = NULL; char *vmx = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&data, 0, sizeof(data));
if (STRNEQ(nativeFormat, VMX_CONFIG_FORMAT_ARGV)) { if (STRNEQ(nativeFormat, VMX_CONFIG_FORMAT_ARGV)) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("Unsupported config format '%1$s'"), nativeFormat); _("Unsupported config format '%1$s'"), nativeFormat);
@ -2870,7 +2864,7 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
esxVI_ObjectContent *virtualMachine = NULL; esxVI_ObjectContent *virtualMachine = NULL;
int virtualHW_version; int virtualHW_version;
virVMXContext ctx; virVMXContext ctx;
esxVMX_Data data; esxVMX_Data data = { 0 };
g_autofree char *datastoreName = NULL; g_autofree char *datastoreName = NULL;
g_autofree char *directoryName = NULL; g_autofree char *directoryName = NULL;
g_autofree char *escapedName = NULL; g_autofree char *escapedName = NULL;
@ -2892,8 +2886,6 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
if (flags & VIR_DOMAIN_DEFINE_VALIDATE) if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
memset(&data, 0, sizeof(data));
if (esxVI_EnsureSession(priv->primary) < 0) if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
@ -4058,14 +4050,12 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL; esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL; esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL; esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL;
virDomainSnapshotDef def; virDomainSnapshotDef def = { 0 };
char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
char *xml = NULL; char *xml = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&def, 0, sizeof(def));
if (esxVI_EnsureSession(priv->primary) < 0) if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;

View File

@ -157,21 +157,16 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
char *xml = NULL; char *xml = NULL;
esxPrivate *priv = iface->conn->privateData; esxPrivate *priv = iface->conn->privateData;
esxVI_PhysicalNic *physicalNic = NULL; esxVI_PhysicalNic *physicalNic = NULL;
virInterfaceDef def; virInterfaceDef def = { 0 };
bool hasAddress = false; bool hasAddress = false;
virInterfaceProtocolDef *protocols; virInterfaceProtocolDef *protocols;
virInterfaceProtocolDef protocol; virInterfaceProtocolDef protocol = { 0 };
virSocketAddr socketAddress; virSocketAddr socketAddress = { 0 };
virInterfaceIPDef *ips; virInterfaceIPDef *ips;
virInterfaceIPDef ip; virInterfaceIPDef ip = { 0 };
virCheckFlags(VIR_INTERFACE_XML_INACTIVE, NULL); virCheckFlags(VIR_INTERFACE_XML_INACTIVE, NULL);
memset(&def, 0, sizeof(def));
memset(&protocol, 0, sizeof(protocol));
memset(&socketAddress, 0, sizeof(socketAddress));
memset(&ip, 0, sizeof(ip));
if (esxVI_EnsureSession(priv->primary) < 0 || if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupPhysicalNicByMACAddress(priv->primary, iface->mac, esxVI_LookupPhysicalNicByMACAddress(priv->primary, iface->mac,
&physicalNic, &physicalNic,

View File

@ -302,12 +302,10 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
esxPrivate *priv = pool->conn->privateData; esxPrivate *priv = pool->conn->privateData;
esxVI_HostInternetScsiHba *hostInternetScsiHba = NULL; esxVI_HostInternetScsiHba *hostInternetScsiHba = NULL;
esxVI_HostInternetScsiHbaStaticTarget *target; esxVI_HostInternetScsiHbaStaticTarget *target;
virStoragePoolDef def; virStoragePoolDef def = { 0 };
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&def, 0, sizeof(def));
if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba)) if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba))
goto cleanup; goto cleanup;
@ -664,20 +662,17 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
{ {
char *xml = NULL; char *xml = NULL;
esxPrivate *priv = volume->conn->privateData; esxPrivate *priv = volume->conn->privateData;
virStoragePoolDef pool; virStoragePoolDef pool = { 0 };
esxVI_ScsiLun *scsiLunList = NULL; esxVI_ScsiLun *scsiLunList = NULL;
esxVI_ScsiLun *scsiLun; esxVI_ScsiLun *scsiLun;
esxVI_HostScsiDisk *hostScsiDisk = NULL; esxVI_HostScsiDisk *hostScsiDisk = NULL;
virStorageVolDef def; virStorageVolDef def = { 0 };
/* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */ /* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */
unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5]; unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5];
char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&pool, 0, sizeof(pool));
memset(&def, 0, sizeof(def));
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup; goto cleanup;

View File

@ -442,15 +442,13 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
esxVI_DatastoreHostMount *hostMount = NULL; esxVI_DatastoreHostMount *hostMount = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_Boolean accessible = esxVI_Boolean_Undefined; esxVI_Boolean accessible = esxVI_Boolean_Undefined;
virStoragePoolDef def; virStoragePoolDef def = { 0 };
esxVI_DatastoreInfo *info = NULL; esxVI_DatastoreInfo *info = NULL;
esxVI_NasDatastoreInfo *nasInfo = NULL; esxVI_NasDatastoreInfo *nasInfo = NULL;
char *xml = NULL; char *xml = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&def, 0, sizeof(def));
if (esxVI_String_AppendValueListToList(&propertyNameList, if (esxVI_String_AppendValueListToList(&propertyNameList,
"summary.accessible\0" "summary.accessible\0"
"summary.capacity\0" "summary.capacity\0"
@ -833,7 +831,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
{ {
virStorageVolPtr volume = NULL; virStorageVolPtr volume = NULL;
esxPrivate *priv = pool->conn->privateData; esxPrivate *priv = pool->conn->privateData;
virStoragePoolDef poolDef; virStoragePoolDef poolDef = { 0 };
char *tmp; char *tmp;
g_autofree char *unescapedDatastorePath = NULL; g_autofree char *unescapedDatastorePath = NULL;
g_autofree char *unescapedDirectoryName = NULL; g_autofree char *unescapedDirectoryName = NULL;
@ -853,8 +851,6 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&poolDef, 0, sizeof(poolDef));
if (esxLookupVMFSStoragePoolType(priv->primary, pool->name, if (esxLookupVMFSStoragePoolType(priv->primary, pool->name,
&poolDef.type) < 0) { &poolDef.type) < 0) {
goto cleanup; goto cleanup;
@ -1032,7 +1028,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
{ {
virStorageVolPtr volume = NULL; virStorageVolPtr volume = NULL;
esxPrivate *priv = pool->conn->privateData; esxPrivate *priv = pool->conn->privateData;
virStoragePoolDef poolDef; virStoragePoolDef poolDef = { 0 };
g_autofree char *sourceDatastorePath = NULL; g_autofree char *sourceDatastorePath = NULL;
char *tmp; char *tmp;
g_autofree char *unescapedDatastorePath = NULL; g_autofree char *unescapedDatastorePath = NULL;
@ -1052,8 +1048,6 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&poolDef, 0, sizeof(poolDef));
if (esxLookupVMFSStoragePoolType(priv->primary, pool->name, if (esxLookupVMFSStoragePoolType(priv->primary, pool->name,
&poolDef.type) < 0) { &poolDef.type) < 0) {
goto cleanup; goto cleanup;
@ -1312,20 +1306,17 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
unsigned int flags) unsigned int flags)
{ {
esxPrivate *priv = volume->conn->privateData; esxPrivate *priv = volume->conn->privateData;
virStoragePoolDef pool; virStoragePoolDef pool = { 0 };
g_autofree char *datastorePath = NULL; g_autofree char *datastorePath = NULL;
esxVI_FileInfo *fileInfo = NULL; esxVI_FileInfo *fileInfo = NULL;
esxVI_VmDiskFileInfo *vmDiskFileInfo = NULL; esxVI_VmDiskFileInfo *vmDiskFileInfo = NULL;
esxVI_IsoImageFileInfo *isoImageFileInfo = NULL; esxVI_IsoImageFileInfo *isoImageFileInfo = NULL;
esxVI_FloppyImageFileInfo *floppyImageFileInfo = NULL; esxVI_FloppyImageFileInfo *floppyImageFileInfo = NULL;
virStorageVolDef def; virStorageVolDef def = { 0 };
char *xml = NULL; char *xml = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&pool, 0, sizeof(pool));
memset(&def, 0, sizeof(def));
if (esxLookupVMFSStoragePoolType(priv->primary, volume->pool, if (esxLookupVMFSStoragePoolType(priv->primary, volume->pool,
&pool.type) < 0) { &pool.type) < 0) {
return NULL; return NULL;

View File

@ -272,13 +272,11 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
int int
esxUtil_ResolveHostname(const char *hostname, char **ipAddress) esxUtil_ResolveHostname(const char *hostname, char **ipAddress)
{ {
struct addrinfo hints; struct addrinfo hints = { 0 };
struct addrinfo *result = NULL; struct addrinfo *result = NULL;
int errcode; int errcode;
g_autofree char *address = NULL; g_autofree char *address = NULL;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_ADDRCONFIG; hints.ai_flags = AI_ADDRCONFIG;
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;

View File

@ -1796,7 +1796,7 @@ libxlDoDomainSave(libxlDriverPrivate *driver,
bool managed) bool managed)
{ {
libxlDriverConfig *cfg = libxlDriverConfigGet(driver); libxlDriverConfig *cfg = libxlDriverConfigGet(driver);
libxlSavefileHeader hdr; libxlSavefileHeader hdr = { 0 };
virObjectEvent *event = NULL; virObjectEvent *event = NULL;
g_autofree char *xml = NULL; g_autofree char *xml = NULL;
uint32_t xml_len; uint32_t xml_len;
@ -1821,7 +1821,6 @@ libxlDoDomainSave(libxlDriverPrivate *driver,
goto cleanup; goto cleanup;
xml_len = strlen(xml) + 1; xml_len = strlen(xml) + 1;
memset(&hdr, 0, sizeof(hdr));
memcpy(hdr.magic, LIBXL_SAVE_MAGIC, sizeof(hdr.magic)); memcpy(hdr.magic, LIBXL_SAVE_MAGIC, sizeof(hdr.magic));
hdr.version = LIBXL_SAVE_VERSION; hdr.version = LIBXL_SAVE_VERSION;
hdr.xmlLen = xml_len; hdr.xmlLen = xml_len;
@ -5651,7 +5650,7 @@ libxlDomainBlockStats(virDomainPtr dom,
virDomainBlockStatsPtr stats) virDomainBlockStatsPtr stats)
{ {
virDomainObj *vm; virDomainObj *vm;
libxlBlockStats blkstats; libxlBlockStats blkstats = { 0 };
int ret = -1; int ret = -1;
if (!(vm = libxlDomObjFromDomain(dom))) if (!(vm = libxlDomObjFromDomain(dom)))
@ -5666,7 +5665,6 @@ libxlDomainBlockStats(virDomainPtr dom,
if (virDomainObjCheckActive(vm) < 0) if (virDomainObjCheckActive(vm) < 0)
goto endjob; goto endjob;
memset(&blkstats, 0, sizeof(libxlBlockStats));
if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0) if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0)
goto endjob; goto endjob;
@ -5695,7 +5693,7 @@ libxlDomainBlockStatsFlags(virDomainPtr dom,
unsigned int flags) unsigned int flags)
{ {
virDomainObj *vm; virDomainObj *vm;
libxlBlockStats blkstats; libxlBlockStats blkstats = { 0 };
int nstats; int nstats;
int ret = -1; int ret = -1;
@ -5722,7 +5720,6 @@ libxlDomainBlockStatsFlags(virDomainPtr dom,
goto endjob; goto endjob;
} }
memset(&blkstats, 0, sizeof(libxlBlockStats));
if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0) if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0)
goto endjob; goto endjob;

View File

@ -138,9 +138,7 @@ virLockManagerLockDaemonConnectionRegister(virLockManager *lock,
int *counter) int *counter)
{ {
virLockManagerLockDaemonPrivate *priv = lock->privateData; virLockManagerLockDaemonPrivate *priv = lock->privateData;
virLockSpaceProtocolRegisterArgs args; virLockSpaceProtocolRegisterArgs args = { 0 };
memset(&args, 0, sizeof(args));
args.flags = 0; args.flags = 0;
memcpy(args.owner.uuid, priv->uuid, VIR_UUID_BUFLEN); memcpy(args.owner.uuid, priv->uuid, VIR_UUID_BUFLEN);
@ -167,9 +165,7 @@ virLockManagerLockDaemonConnectionRestrict(virLockManager *lock G_GNUC_UNUSED,
virNetClientProgram *program, virNetClientProgram *program,
int *counter) int *counter)
{ {
virLockSpaceProtocolRestrictArgs args; virLockSpaceProtocolRestrictArgs args = { 0 };
memset(&args, 0, sizeof(args));
args.flags = 0; args.flags = 0;
@ -259,11 +255,10 @@ static int virLockManagerLockDaemonSetupLockspace(const char *path)
{ {
virNetClient *client; virNetClient *client;
virNetClientProgram *program = NULL; virNetClientProgram *program = NULL;
virLockSpaceProtocolCreateLockSpaceArgs args; virLockSpaceProtocolCreateLockSpaceArgs args = { 0 };
int rv = -1; int rv = -1;
int counter = 0; int counter = 0;
memset(&args, 0, sizeof(args));
args.path = (char*)path; args.path = (char*)path;
if (!(client = virLockManagerLockDaemonConnectionNew(geteuid() == 0, &program))) if (!(client = virLockManagerLockDaemonConnectionNew(geteuid() == 0, &program)))
@ -671,9 +666,7 @@ static int virLockManagerLockDaemonAcquire(virLockManager *lock,
if (!(flags & VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY)) { if (!(flags & VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY)) {
size_t i; size_t i;
for (i = 0; i < priv->nresources; i++) { for (i = 0; i < priv->nresources; i++) {
virLockSpaceProtocolAcquireResourceArgs args; virLockSpaceProtocolAcquireResourceArgs args = { 0 };
memset(&args, 0, sizeof(args));
args.path = priv->resources[i].lockspace; args.path = priv->resources[i].lockspace;
args.name = priv->resources[i].name; args.name = priv->resources[i].name;
@ -726,9 +719,7 @@ static int virLockManagerLockDaemonRelease(virLockManager *lock,
goto cleanup; goto cleanup;
for (i = 0; i < priv->nresources; i++) { for (i = 0; i < priv->nresources; i++) {
virLockSpaceProtocolReleaseResourceArgs args; virLockSpaceProtocolReleaseResourceArgs args = { 0 };
memset(&args, 0, sizeof(args));
if (priv->resources[i].lockspace) if (priv->resources[i].lockspace)
args.path = priv->resources[i].lockspace; args.path = priv->resources[i].lockspace;

View File

@ -149,15 +149,12 @@ virLogManagerDomainOpenLogFile(virLogManager *mgr,
ino_t *inode, ino_t *inode,
off_t *offset) off_t *offset)
{ {
struct virLogManagerProtocolDomainOpenLogFileArgs args; struct virLogManagerProtocolDomainOpenLogFileArgs args = { 0 };
struct virLogManagerProtocolDomainOpenLogFileRet ret; struct virLogManagerProtocolDomainOpenLogFileRet ret = { 0 };
int *fdout = NULL; int *fdout = NULL;
size_t fdoutlen = 0; size_t fdoutlen = 0;
int rv = -1; int rv = -1;
memset(&args, 0, sizeof(args));
memset(&ret, 0, sizeof(ret));
args.driver = (char *)driver; args.driver = (char *)driver;
memcpy(args.dom.uuid, domuuid, VIR_UUID_BUFLEN); memcpy(args.dom.uuid, domuuid, VIR_UUID_BUFLEN);
args.dom.name = (char *)domname; args.dom.name = (char *)domname;
@ -208,11 +205,8 @@ virLogManagerDomainGetLogFilePosition(virLogManager *mgr,
ino_t *inode, ino_t *inode,
off_t *offset) off_t *offset)
{ {
struct virLogManagerProtocolDomainGetLogFilePositionArgs args; struct virLogManagerProtocolDomainGetLogFilePositionArgs args = { 0 };
struct virLogManagerProtocolDomainGetLogFilePositionRet ret; struct virLogManagerProtocolDomainGetLogFilePositionRet ret = { 0 };
memset(&args, 0, sizeof(args));
memset(&ret, 0, sizeof(ret));
args.path = (char *)path; args.path = (char *)path;
args.flags = flags; args.flags = flags;
@ -241,11 +235,8 @@ virLogManagerDomainReadLogFile(virLogManager *mgr,
size_t maxlen, size_t maxlen,
unsigned int flags) unsigned int flags)
{ {
struct virLogManagerProtocolDomainReadLogFileArgs args; struct virLogManagerProtocolDomainReadLogFileArgs args = { 0 };
struct virLogManagerProtocolDomainReadLogFileRet ret; struct virLogManagerProtocolDomainReadLogFileRet ret = { 0 };
memset(&args, 0, sizeof(args));
memset(&ret, 0, sizeof(ret));
args.path = (char *)path; args.path = (char *)path;
args.flags = flags; args.flags = flags;
@ -275,11 +266,9 @@ virLogManagerDomainAppendMessage(virLogManager *mgr,
const char *message, const char *message,
unsigned int flags) unsigned int flags)
{ {
struct virLogManagerProtocolDomainAppendLogFileArgs args; struct virLogManagerProtocolDomainAppendLogFileArgs args = { 0 };
struct virLogManagerProtocolDomainAppendLogFileRet ret; struct virLogManagerProtocolDomainAppendLogFileRet ret;
memset(&args, 0, sizeof(args));
args.driver = (char *)driver; args.driver = (char *)driver;
memcpy(args.dom.uuid, domuuid, VIR_UUID_BUFLEN); memcpy(args.dom.uuid, domuuid, VIR_UUID_BUFLEN);
args.dom.name = (char *)domname; args.dom.name = (char *)domname;

View File

@ -2235,10 +2235,9 @@ static int
virLXCControllerEventSendExit(virLXCController *ctrl, virLXCControllerEventSendExit(virLXCController *ctrl,
int exitstatus) int exitstatus)
{ {
virLXCMonitorExitEventMsg msg; virLXCMonitorExitEventMsg msg = { 0 };
VIR_DEBUG("Exit status %d (client=%p)", exitstatus, ctrl->client); VIR_DEBUG("Exit status %d (client=%p)", exitstatus, ctrl->client);
memset(&msg, 0, sizeof(msg));
switch (exitstatus) { switch (exitstatus) {
case 0: case 0:
msg.status = VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN; msg.status = VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN;
@ -2272,10 +2271,9 @@ static int
virLXCControllerEventSendInit(virLXCController *ctrl, virLXCControllerEventSendInit(virLXCController *ctrl,
pid_t initpid) pid_t initpid)
{ {
virLXCMonitorInitEventMsg msg; virLXCMonitorInitEventMsg msg = { 0 };
VIR_DEBUG("Init pid %lld", (long long)initpid); VIR_DEBUG("Init pid %lld", (long long)initpid);
memset(&msg, 0, sizeof(msg));
msg.initpid = initpid; msg.initpid = initpid;
virLXCControllerEventSend(ctrl, virLXCControllerEventSend(ctrl,

View File

@ -339,13 +339,11 @@ virLXCDomainSetRunlevel(virDomainObj *vm,
int runlevel) int runlevel)
{ {
virLXCDomainObjPrivate *priv = vm->privateData; virLXCDomainObjPrivate *priv = vm->privateData;
lxcDomainInitctlCallbackData data; lxcDomainInitctlCallbackData data = { 0 };
size_t nfifos = 0; size_t nfifos = 0;
size_t i; size_t i;
int ret = -1; int ret = -1;
memset(&data, 0, sizeof(data));
data.runlevel = runlevel; data.runlevel = runlevel;
for (nfifos = 0; virInitctlFifos[nfifos]; nfifos++) for (nfifos = 0; virInitctlFifos[nfifos]; nfifos++)

View File

@ -3327,9 +3327,7 @@ lxcDomainAttachDeviceMknod(virLXCDriver *driver,
char *file) char *file)
{ {
virLXCDomainObjPrivate *priv = vm->privateData; virLXCDomainObjPrivate *priv = vm->privateData;
struct lxcDomainAttachDeviceMknodData data; struct lxcDomainAttachDeviceMknodData data = { 0 };
memset(&data, 0, sizeof(data));
data.driver = driver; data.driver = driver;
data.mode = mode; data.mode = mode;

View File

@ -817,7 +817,7 @@ virNWFilterSnoopDHCPDecode(virNWFilterSnoopReq *req,
struct iphdr *pip; struct iphdr *pip;
struct udphdr *pup; struct udphdr *pup;
virNWFilterSnoopDHCPHdr *pd; virNWFilterSnoopDHCPHdr *pd;
virNWFilterSnoopIPLease ipl; virNWFilterSnoopIPLease ipl = { 0 };
uint8_t mtype; uint8_t mtype;
uint32_t leasetime; uint32_t leasetime;
uint32_t nwint; uint32_t nwint;
@ -863,8 +863,6 @@ virNWFilterSnoopDHCPDecode(virNWFilterSnoopReq *req,
if (virNWFilterSnoopDHCPGetOpt(pd, len, &mtype, &leasetime) < 0) if (virNWFilterSnoopDHCPGetOpt(pd, len, &mtype, &leasetime) < 0)
return -2; return -2;
memset(&ipl, 0, sizeof(ipl));
memcpy(&nwint, &pd->d_yiaddr, sizeof(nwint)); memcpy(&nwint, &pd->d_yiaddr, sizeof(nwint));
virSocketAddrSetIPv4AddrNetOrder(&ipl.ipAddress, nwint); virSocketAddrSetIPv4AddrNetOrder(&ipl.ipAddress, nwint);

View File

@ -463,7 +463,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriver *techdriver,
bool forceWithPendingReq) bool forceWithPendingReq)
{ {
int rc; int rc;
virNWFilterInst inst; virNWFilterInst inst = { 0 };
bool instantiate = true; bool instantiate = true;
g_autofree char *buf = NULL; g_autofree char *buf = NULL;
virNWFilterVarValue *lv; virNWFilterVarValue *lv;
@ -471,8 +471,6 @@ virNWFilterDoInstantiate(virNWFilterTechDriver *techdriver,
bool reportIP = false; bool reportIP = false;
g_autoptr(GHashTable) missing_vars = virHashNew(virNWFilterVarValueHashFree); g_autoptr(GHashTable) missing_vars = virHashNew(virNWFilterVarValueHashFree);
memset(&inst, 0, sizeof(inst));
rc = virNWFilterDetermineMissingVarsRec(filter, rc = virNWFilterDetermineMissingVarsRec(filter,
binding->filterparams, binding->filterparams,
missing_vars, missing_vars,

View File

@ -149,7 +149,7 @@ static void qemuAgentDispose(void *obj)
static int static int
qemuAgentOpenUnix(const char *socketpath) qemuAgentOpenUnix(const char *socketpath)
{ {
struct sockaddr_un addr; struct sockaddr_un addr = { 0 };
int agentfd; int agentfd;
if ((agentfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { if ((agentfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
@ -165,7 +165,6 @@ qemuAgentOpenUnix(const char *socketpath)
goto error; goto error;
} }
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
if (virStrcpyStatic(addr.sun_path, socketpath) < 0) { if (virStrcpyStatic(addr.sun_path, socketpath) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -803,11 +802,9 @@ qemuAgentGuestSyncSend(qemuAgent *agent,
g_autofree char *txMsg = NULL; g_autofree char *txMsg = NULL;
g_autoptr(virJSONValue) rxObj = NULL; g_autoptr(virJSONValue) rxObj = NULL;
unsigned long long id; unsigned long long id;
qemuAgentMessage sync_msg; qemuAgentMessage sync_msg = { 0 };
int rc; int rc;
memset(&sync_msg, 0, sizeof(sync_msg));
if (virTimeMillisNow(&id) < 0) if (virTimeMillisNow(&id) < 0)
return -1; return -1;
@ -1015,12 +1012,11 @@ qemuAgentCommandFull(qemuAgent *agent,
bool report_unsupported) bool report_unsupported)
{ {
int ret = -1; int ret = -1;
qemuAgentMessage msg; qemuAgentMessage msg = { 0 };
g_autofree char *cmdstr = NULL; g_autofree char *cmdstr = NULL;
int await_event = agent->await_event; int await_event = agent->await_event;
*reply = NULL; *reply = NULL;
memset(&msg, 0, sizeof(msg));
if (!agent->running) { if (!agent->running) {
virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s", virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",

View File

@ -4868,7 +4868,7 @@ qemuBuildSCSIHostdevDevProps(const virDomainDef *def,
int int
qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev)
{ {
struct sockaddr_un addr; struct sockaddr_un addr = { 0 };
socklen_t addrlen = sizeof(addr); socklen_t addrlen = sizeof(addr);
int fd; int fd;
@ -4878,7 +4878,6 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev)
goto error; goto error;
} }
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
if (virStrcpyStatic(addr.sun_path, dev->data.nix.path) < 0) { if (virStrcpyStatic(addr.sun_path, dev->data.nix.path) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,

View File

@ -14933,8 +14933,8 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
qemuDomainObjPrivate *priv; qemuDomainObjPrivate *priv;
virDomainDef *def = NULL; virDomainDef *def = NULL;
virDomainDef *persistentDef = NULL; virDomainDef *persistentDef = NULL;
virDomainBlockIoTuneInfo info; virDomainBlockIoTuneInfo info = { 0 };
virDomainBlockIoTuneInfo conf_info; virDomainBlockIoTuneInfo conf_info = { 0 };
int ret = -1; int ret = -1;
size_t i; size_t i;
virDomainDiskDef *conf_disk = NULL; virDomainDiskDef *conf_disk = NULL;
@ -14995,9 +14995,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
NULL) < 0) NULL) < 0)
return -1; return -1;
memset(&info, 0, sizeof(info));
memset(&conf_info, 0, sizeof(conf_info));
if (!(vm = qemuDomainObjFromDomain(dom))) if (!(vm = qemuDomainObjFromDomain(dom)))
return -1; return -1;

View File

@ -227,7 +227,7 @@ qemuMonitorDispose(void *obj)
static int static int
qemuMonitorOpenUnix(const char *monitor) qemuMonitorOpenUnix(const char *monitor)
{ {
struct sockaddr_un addr; struct sockaddr_un addr = { 0 };
VIR_AUTOCLOSE monfd = -1; VIR_AUTOCLOSE monfd = -1;
int ret = -1; int ret = -1;
@ -237,7 +237,6 @@ qemuMonitorOpenUnix(const char *monitor)
return -1; return -1;
} }
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
if (virStrcpyStatic(addr.sun_path, monitor) < 0) { if (virStrcpyStatic(addr.sun_path, monitor) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -309,13 +308,12 @@ qemuMonitorIOWriteWithFD(qemuMonitor *mon,
size_t len, size_t len,
int fd) int fd)
{ {
struct msghdr msg; struct msghdr msg = { 0 };
struct iovec iov[1]; struct iovec iov[1];
int ret; int ret;
char control[CMSG_SPACE(sizeof(int))]; char control[CMSG_SPACE(sizeof(int))];
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
memset(&msg, 0, sizeof(msg));
memset(control, 0, sizeof(control)); memset(control, 0, sizeof(control));
iov[0].iov_base = (void *)data; iov[0].iov_base = (void *)data;

View File

@ -259,13 +259,11 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon,
virJSONValue **reply) virJSONValue **reply)
{ {
int ret = -1; int ret = -1;
qemuMonitorMessage msg; qemuMonitorMessage msg = { 0 };
g_auto(virBuffer) cmdbuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) cmdbuf = VIR_BUFFER_INITIALIZER;
*reply = NULL; *reply = NULL;
memset(&msg, 0, sizeof(msg));
if (virJSONValueObjectHasKey(cmd, "execute")) { if (virJSONValueObjectHasKey(cmd, "execute")) {
g_autofree char *id = qemuMonitorNextCommandID(mon); g_autofree char *id = qemuMonitorNextCommandID(mon);
@ -2035,10 +2033,9 @@ qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitor *mon,
char *balloonpath, char *balloonpath,
int period) int period)
{ {
qemuMonitorJSONObjectProperty prop; qemuMonitorJSONObjectProperty prop = { 0 };
/* Set to the value in memballoon (could enable or disable) */ /* Set to the value in memballoon (could enable or disable) */
memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT; prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT;
prop.val.iv = period; prop.val.iv = period;
if (qemuMonitorJSONSetObjectProperty(mon, balloonpath, if (qemuMonitorJSONSetObjectProperty(mon, balloonpath,

View File

@ -2226,14 +2226,13 @@ qemuRefreshRTC(virDomainObj *vm)
{ {
qemuDomainObjPrivate *priv = vm->privateData; qemuDomainObjPrivate *priv = vm->privateData;
time_t now, then; time_t now, then;
struct tm thenbits; struct tm thenbits = { 0 };
long localOffset; long localOffset;
int rv; int rv;
if (vm->def->clock.offset != VIR_DOMAIN_CLOCK_OFFSET_VARIABLE) if (vm->def->clock.offset != VIR_DOMAIN_CLOCK_OFFSET_VARIABLE)
return; return;
memset(&thenbits, 0, sizeof(thenbits));
qemuDomainObjEnterMonitor(vm); qemuDomainObjEnterMonitor(vm);
now = time(NULL); now = time(NULL);
rv = qemuMonitorGetRTCTime(priv->mon, &thenbits); rv = qemuMonitorGetRTCTime(priv->mon, &thenbits);

View File

@ -313,7 +313,7 @@ remoteRelayDomainEventLifecycle(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_lifecycle_msg data; remote_domain_event_lifecycle_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -323,7 +323,6 @@ remoteRelayDomainEventLifecycle(virConnectPtr conn,
event, detail, callback->callbackID, callback->legacy); event, detail, callback->callbackID, callback->legacy);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
data.event = event; data.event = event;
data.detail = detail; data.detail = detail;
@ -352,7 +351,7 @@ remoteRelayDomainEventReboot(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_reboot_msg data; remote_domain_event_reboot_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -362,7 +361,6 @@ remoteRelayDomainEventReboot(virConnectPtr conn,
dom->name, dom->id, callback->callbackID, callback->legacy); dom->name, dom->id, callback->callbackID, callback->legacy);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
if (callback->legacy) { if (callback->legacy) {
@ -389,7 +387,7 @@ remoteRelayDomainEventRTCChange(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_rtc_change_msg data; remote_domain_event_rtc_change_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -400,7 +398,6 @@ remoteRelayDomainEventRTCChange(virConnectPtr conn,
callback->callbackID, callback->legacy); callback->callbackID, callback->legacy);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
data.offset = offset; data.offset = offset;
@ -428,7 +425,7 @@ remoteRelayDomainEventWatchdog(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_watchdog_msg data; remote_domain_event_watchdog_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -438,7 +435,6 @@ remoteRelayDomainEventWatchdog(virConnectPtr conn,
dom->name, dom->id, action, callback->callbackID); dom->name, dom->id, action, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
data.action = action; data.action = action;
@ -468,7 +464,7 @@ remoteRelayDomainEventIOError(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_io_error_msg data; remote_domain_event_io_error_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -479,7 +475,6 @@ remoteRelayDomainEventIOError(virConnectPtr conn,
callback->callbackID); callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.srcPath = g_strdup(srcPath); data.srcPath = g_strdup(srcPath);
data.devAlias = g_strdup(devAlias); data.devAlias = g_strdup(devAlias);
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
@ -512,7 +507,7 @@ remoteRelayDomainEventIOErrorReason(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_io_error_reason_msg data; remote_domain_event_io_error_reason_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -523,7 +518,6 @@ remoteRelayDomainEventIOErrorReason(virConnectPtr conn,
callback->callbackID); callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.srcPath = g_strdup(srcPath); data.srcPath = g_strdup(srcPath);
data.devAlias = g_strdup(devAlias); data.devAlias = g_strdup(devAlias);
data.reason = g_strdup(reason); data.reason = g_strdup(reason);
@ -558,7 +552,7 @@ remoteRelayDomainEventGraphics(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_graphics_msg data; remote_domain_event_graphics_msg data = { 0 };
size_t i; size_t i;
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
@ -576,7 +570,6 @@ remoteRelayDomainEventGraphics(virConnectPtr conn,
VIR_DEBUG(" %s=%s", subject->identities[i].type, subject->identities[i].name); VIR_DEBUG(" %s=%s", subject->identities[i].type, subject->identities[i].name);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.phase = phase; data.phase = phase;
data.local.family = local->family; data.local.family = local->family;
data.remote.family = remote->family; data.remote.family = remote->family;
@ -625,7 +618,7 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_block_job_msg data; remote_domain_event_block_job_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -635,7 +628,6 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn,
dom->name, dom->id, path, type, status, callback->callbackID); dom->name, dom->id, path, type, status, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.path = g_strdup(path); data.path = g_strdup(path);
data.type = type; data.type = type;
data.status = status; data.status = status;
@ -664,7 +656,7 @@ remoteRelayDomainEventControlError(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_control_error_msg data; remote_domain_event_control_error_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -674,7 +666,6 @@ remoteRelayDomainEventControlError(virConnectPtr conn,
dom->name, dom->id, callback->callbackID); dom->name, dom->id, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
if (callback->legacy) { if (callback->legacy) {
@ -704,7 +695,7 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_disk_change_msg data; remote_domain_event_disk_change_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -715,7 +706,6 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn,
callback->callbackID); callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
if (oldSrcPath) { if (oldSrcPath) {
data.oldSrcPath = g_new0(remote_nonnull_string, 1); data.oldSrcPath = g_new0(remote_nonnull_string, 1);
*(data.oldSrcPath) = g_strdup(oldSrcPath); *(data.oldSrcPath) = g_strdup(oldSrcPath);
@ -755,7 +745,7 @@ remoteRelayDomainEventTrayChange(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_tray_change_msg data; remote_domain_event_tray_change_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -765,8 +755,6 @@ remoteRelayDomainEventTrayChange(virConnectPtr conn,
dom->name, dom->id, devAlias, reason, callback->callbackID); dom->name, dom->id, devAlias, reason, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.devAlias = g_strdup(devAlias); data.devAlias = g_strdup(devAlias);
data.reason = reason; data.reason = reason;
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
@ -794,7 +782,7 @@ remoteRelayDomainEventPMWakeup(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_pmwakeup_msg data; remote_domain_event_pmwakeup_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -804,7 +792,6 @@ remoteRelayDomainEventPMWakeup(virConnectPtr conn,
dom->name, dom->id, callback->callbackID); dom->name, dom->id, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
if (callback->legacy) { if (callback->legacy) {
@ -830,7 +817,7 @@ remoteRelayDomainEventPMSuspend(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_pmsuspend_msg data; remote_domain_event_pmsuspend_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -840,7 +827,6 @@ remoteRelayDomainEventPMSuspend(virConnectPtr conn,
dom->name, dom->id, callback->callbackID); dom->name, dom->id, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
if (callback->legacy) { if (callback->legacy) {
@ -866,7 +852,7 @@ remoteRelayDomainEventBalloonChange(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_balloon_change_msg data; remote_domain_event_balloon_change_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -876,7 +862,6 @@ remoteRelayDomainEventBalloonChange(virConnectPtr conn,
dom->name, dom->id, actual, callback->callbackID); dom->name, dom->id, actual, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
data.actual = actual; data.actual = actual;
@ -904,7 +889,7 @@ remoteRelayDomainEventPMSuspendDisk(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_pmsuspend_disk_msg data; remote_domain_event_pmsuspend_disk_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -914,7 +899,6 @@ remoteRelayDomainEventPMSuspendDisk(virConnectPtr conn,
dom->name, dom->id, callback->callbackID); dom->name, dom->id, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
if (callback->legacy) { if (callback->legacy) {
@ -940,7 +924,7 @@ remoteRelayDomainEventDeviceRemoved(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_device_removed_msg data; remote_domain_event_device_removed_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -950,8 +934,6 @@ remoteRelayDomainEventDeviceRemoved(virConnectPtr conn,
dom->name, dom->id, devAlias, callback->callbackID); dom->name, dom->id, devAlias, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.devAlias = g_strdup(devAlias); data.devAlias = g_strdup(devAlias);
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
@ -984,7 +966,7 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_block_job_2_msg data; remote_domain_event_block_job_2_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -994,7 +976,6 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
dom->name, dom->id, dst, type, status, callback->callbackID); dom->name, dom->id, dst, type, status, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.dst = g_strdup(dst); data.dst = g_strdup(dst);
data.type = type; data.type = type;
@ -1017,7 +998,7 @@ remoteRelayDomainEventTunable(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_callback_tunable_msg data; remote_domain_event_callback_tunable_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -1027,8 +1008,6 @@ remoteRelayDomainEventTunable(virConnectPtr conn,
dom->name, dom->id, callback->callbackID, params, nparams); dom->name, dom->id, callback->callbackID, params, nparams);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
if (virTypedParamsSerialize(params, nparams, if (virTypedParamsSerialize(params, nparams,
REMOTE_DOMAIN_EVENT_TUNABLE_MAX, REMOTE_DOMAIN_EVENT_TUNABLE_MAX,
(struct _virTypedParameterRemote **) &data.params.params_val, (struct _virTypedParameterRemote **) &data.params.params_val,
@ -1057,7 +1036,7 @@ remoteRelayDomainEventAgentLifecycle(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_callback_agent_lifecycle_msg data; remote_domain_event_callback_agent_lifecycle_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -1068,7 +1047,6 @@ remoteRelayDomainEventAgentLifecycle(virConnectPtr conn,
dom->name, dom->id, callback->callbackID, state, reason); dom->name, dom->id, callback->callbackID, state, reason);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
data.state = state; data.state = state;
@ -1090,7 +1068,7 @@ remoteRelayDomainEventDeviceAdded(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_callback_device_added_msg data; remote_domain_event_callback_device_added_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -1100,8 +1078,6 @@ remoteRelayDomainEventDeviceAdded(virConnectPtr conn,
dom->name, dom->id, devAlias, callback->callbackID); dom->name, dom->id, devAlias, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.devAlias = g_strdup(devAlias); data.devAlias = g_strdup(devAlias);
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
@ -1122,7 +1098,7 @@ remoteRelayDomainEventMigrationIteration(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_callback_migration_iteration_msg data; remote_domain_event_callback_migration_iteration_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -1133,7 +1109,6 @@ remoteRelayDomainEventMigrationIteration(virConnectPtr conn,
dom->name, dom->id, callback->callbackID, iteration); dom->name, dom->id, callback->callbackID, iteration);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
@ -1156,7 +1131,7 @@ remoteRelayDomainEventJobCompleted(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_callback_job_completed_msg data; remote_domain_event_callback_job_completed_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -1167,8 +1142,6 @@ remoteRelayDomainEventJobCompleted(virConnectPtr conn,
dom->name, dom->id, callback->callbackID, params, nparams); dom->name, dom->id, callback->callbackID, params, nparams);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
if (virTypedParamsSerialize(params, nparams, if (virTypedParamsSerialize(params, nparams,
REMOTE_DOMAIN_JOB_STATS_MAX, REMOTE_DOMAIN_JOB_STATS_MAX,
(struct _virTypedParameterRemote **) &data.params.params_val, (struct _virTypedParameterRemote **) &data.params.params_val,
@ -1194,7 +1167,7 @@ remoteRelayDomainEventDeviceRemovalFailed(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_callback_device_removal_failed_msg data; remote_domain_event_callback_device_removal_failed_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -1204,8 +1177,6 @@ remoteRelayDomainEventDeviceRemovalFailed(virConnectPtr conn,
dom->name, dom->id, devAlias, callback->callbackID); dom->name, dom->id, devAlias, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.devAlias = g_strdup(devAlias); data.devAlias = g_strdup(devAlias);
make_nonnull_domain(&data.dom, dom); make_nonnull_domain(&data.dom, dom);
@ -1228,7 +1199,7 @@ remoteRelayDomainEventMetadataChange(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_callback_metadata_change_msg data; remote_domain_event_callback_metadata_change_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -1238,8 +1209,6 @@ remoteRelayDomainEventMetadataChange(virConnectPtr conn,
dom->name, dom->id, type, NULLSTR(nsuri), callback->callbackID); dom->name, dom->id, type, NULLSTR(nsuri), callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.type = type; data.type = type;
if (nsuri) { if (nsuri) {
data.nsuri = g_new0(remote_nonnull_string, 1); data.nsuri = g_new0(remote_nonnull_string, 1);
@ -1268,7 +1237,7 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_block_threshold_msg data; remote_domain_event_block_threshold_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
@ -1278,7 +1247,6 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr conn,
dom->name, dom->id, dev, NULLSTR(path), threshold, excess, callback->callbackID); dom->name, dom->id, dev, NULLSTR(path), threshold, excess, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.dev = g_strdup(dev); data.dev = g_strdup(dev);
if (path) { if (path) {
@ -1306,14 +1274,13 @@ remoteRelayDomainEventMemoryFailure(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_memory_failure_msg data; remote_domain_event_memory_failure_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
return -1; return -1;
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.recipient = recipient; data.recipient = recipient;
data.action = action; data.action = action;
@ -1336,14 +1303,13 @@ remoteRelayDomainEventMemoryDeviceSizeChange(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_domain_event_memory_device_size_change_msg data; remote_domain_event_memory_device_size_change_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainEventCheckACL(callback->client, conn, dom)) !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
return -1; return -1;
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.alias = g_strdup(alias); data.alias = g_strdup(alias);
data.size = size; data.size = size;
@ -1397,7 +1363,7 @@ remoteRelayNetworkEventLifecycle(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_network_event_lifecycle_msg data; remote_network_event_lifecycle_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayNetworkEventCheckACL(callback->client, conn, net)) !remoteRelayNetworkEventCheckACL(callback->client, conn, net))
@ -1407,7 +1373,6 @@ remoteRelayNetworkEventLifecycle(virConnectPtr conn,
event, detail, callback->callbackID); event, detail, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_network(&data.net, net); make_nonnull_network(&data.net, net);
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.event = event; data.event = event;
@ -1434,7 +1399,7 @@ remoteRelayStoragePoolEventLifecycle(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_storage_pool_event_lifecycle_msg data; remote_storage_pool_event_lifecycle_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayStoragePoolEventCheckACL(callback->client, conn, pool)) !remoteRelayStoragePoolEventCheckACL(callback->client, conn, pool))
@ -1444,7 +1409,6 @@ remoteRelayStoragePoolEventLifecycle(virConnectPtr conn,
event, detail, callback->callbackID); event, detail, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_storage_pool(&data.pool, pool); make_nonnull_storage_pool(&data.pool, pool);
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.event = event; data.event = event;
@ -1464,7 +1428,7 @@ remoteRelayStoragePoolEventRefresh(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_storage_pool_event_refresh_msg data; remote_storage_pool_event_refresh_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayStoragePoolEventCheckACL(callback->client, conn, pool)) !remoteRelayStoragePoolEventCheckACL(callback->client, conn, pool))
@ -1474,7 +1438,6 @@ remoteRelayStoragePoolEventRefresh(virConnectPtr conn,
callback->callbackID); callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_storage_pool(&data.pool, pool); make_nonnull_storage_pool(&data.pool, pool);
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
@ -1501,7 +1464,7 @@ remoteRelayNodeDeviceEventLifecycle(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_node_device_event_lifecycle_msg data; remote_node_device_event_lifecycle_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayNodeDeviceEventCheckACL(callback->client, conn, dev)) !remoteRelayNodeDeviceEventCheckACL(callback->client, conn, dev))
@ -1511,7 +1474,6 @@ remoteRelayNodeDeviceEventLifecycle(virConnectPtr conn,
event, detail, callback->callbackID); event, detail, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_node_device(&data.dev, dev); make_nonnull_node_device(&data.dev, dev);
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.event = event; data.event = event;
@ -1531,7 +1493,7 @@ remoteRelayNodeDeviceEventUpdate(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_node_device_event_update_msg data; remote_node_device_event_update_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayNodeDeviceEventCheckACL(callback->client, conn, dev)) !remoteRelayNodeDeviceEventCheckACL(callback->client, conn, dev))
@ -1541,7 +1503,6 @@ remoteRelayNodeDeviceEventUpdate(virConnectPtr conn,
callback->callbackID); callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_node_device(&data.dev, dev); make_nonnull_node_device(&data.dev, dev);
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
@ -1568,7 +1529,7 @@ remoteRelaySecretEventLifecycle(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_secret_event_lifecycle_msg data; remote_secret_event_lifecycle_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelaySecretEventCheckACL(callback->client, conn, secret)) !remoteRelaySecretEventCheckACL(callback->client, conn, secret))
@ -1578,7 +1539,6 @@ remoteRelaySecretEventLifecycle(virConnectPtr conn,
event, detail, callback->callbackID); event, detail, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_secret(&data.secret, secret); make_nonnull_secret(&data.secret, secret);
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.event = event; data.event = event;
@ -1598,7 +1558,7 @@ remoteRelaySecretEventValueChanged(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
remote_secret_event_value_changed_msg data; remote_secret_event_value_changed_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelaySecretEventCheckACL(callback->client, conn, secret)) !remoteRelaySecretEventCheckACL(callback->client, conn, secret))
@ -1608,7 +1568,6 @@ remoteRelaySecretEventValueChanged(virConnectPtr conn,
callback->callbackID); callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
make_nonnull_secret(&data.secret, secret); make_nonnull_secret(&data.secret, secret);
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
@ -1637,7 +1596,7 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn,
void *opaque) void *opaque)
{ {
daemonClientEventCallback *callback = opaque; daemonClientEventCallback *callback = opaque;
qemu_domain_monitor_event_msg data; qemu_domain_monitor_event_msg data = { 0 };
if (callback->callbackID < 0 || if (callback->callbackID < 0 ||
!remoteRelayDomainQemuMonitorEventCheckACL(callback->client, conn, !remoteRelayDomainQemuMonitorEventCheckACL(callback->client, conn,
@ -1648,7 +1607,6 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn,
event, details, callback->callbackID); event, details, callback->callbackID);
/* build return data */ /* build return data */
memset(&data, 0, sizeof(data));
data.callbackID = callback->callbackID; data.callbackID = callback->callbackID;
data.event = g_strdup(event); data.event = g_strdup(event);
data.seconds = seconds; data.seconds = seconds;
@ -2677,14 +2635,13 @@ remoteDispatchNodeGetSecurityModel(virNetServer *server G_GNUC_UNUSED,
struct virNetMessageError *rerr, struct virNetMessageError *rerr,
remote_node_get_security_model_ret *ret) remote_node_get_security_model_ret *ret)
{ {
virSecurityModel secmodel; virSecurityModel secmodel = { 0 };
int rv = -1; int rv = -1;
virConnectPtr conn = remoteGetHypervisorConn(client); virConnectPtr conn = remoteGetHypervisorConn(client);
if (!conn) if (!conn)
goto cleanup; goto cleanup;
memset(&secmodel, 0, sizeof(secmodel));
if (virNodeGetSecurityModel(conn, &secmodel) < 0) if (virNodeGetSecurityModel(conn, &secmodel) < 0)
goto cleanup; goto cleanup;

View File

@ -226,12 +226,11 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
(events & (VIR_STREAM_EVENT_ERROR | VIR_STREAM_EVENT_HANGUP))) { (events & (VIR_STREAM_EVENT_ERROR | VIR_STREAM_EVENT_HANGUP))) {
int ret; int ret;
virNetMessage *msg; virNetMessage *msg;
virNetMessageError rerr; virNetMessageError rerr = { 0 };
virErrorPtr origErr; virErrorPtr origErr;
virErrorPreserveLast(&origErr); virErrorPreserveLast(&origErr);
memset(&rerr, 0, sizeof(rerr));
stream->closed = true; stream->closed = true;
virStreamEventRemoveCallback(stream->st); virStreamEventRemoveCallback(stream->st);
virStreamAbort(stream->st); virStreamAbort(stream->st);
@ -565,13 +564,11 @@ daemonStreamHandleWriteData(virNetServerClient *client,
/* Blocking, so indicate we have more todo later */ /* Blocking, so indicate we have more todo later */
return 1; return 1;
} else if (ret < 0) { } else if (ret < 0) {
virNetMessageError rerr; virNetMessageError rerr = { 0 };
virErrorPtr err; virErrorPtr err;
virErrorPreserveLast(&err); virErrorPreserveLast(&err);
memset(&rerr, 0, sizeof(rerr));
VIR_INFO("Stream send failed"); VIR_INFO("Stream send failed");
stream->closed = true; stream->closed = true;
virStreamEventRemoveCallback(stream->st); virStreamEventRemoveCallback(stream->st);
@ -613,8 +610,8 @@ daemonStreamHandleFinish(virNetServerClient *client,
ret = virStreamFinish(stream->st); ret = virStreamFinish(stream->st);
if (ret < 0) { if (ret < 0) {
virNetMessageError rerr; virNetMessageError rerr = { 0 };
memset(&rerr, 0, sizeof(rerr));
return virNetServerProgramSendReplyError(stream->prog, return virNetServerProgramSendReplyError(stream->prog,
client, client,
msg, msg,
@ -663,8 +660,8 @@ daemonStreamHandleAbort(virNetServerClient *client,
} }
if (raise_error) { if (raise_error) {
virNetMessageError rerr; virNetMessageError rerr = { 0 };
memset(&rerr, 0, sizeof(rerr));
return virNetServerProgramSendReplyError(stream->prog, return virNetServerProgramSendReplyError(stream->prog,
client, client,
msg, msg,
@ -709,9 +706,7 @@ daemonStreamHandleHole(virNetServerClient *client,
ret = virStreamSendHole(stream->st, data.length, data.flags); ret = virStreamSendHole(stream->st, data.length, data.flags);
if (ret < 0) { if (ret < 0) {
virNetMessageError rerr; virNetMessageError rerr = { 0 };
memset(&rerr, 0, sizeof(rerr));
VIR_INFO("Stream send hole failed"); VIR_INFO("Stream send hole failed");
stream->closed = true; stream->closed = true;
@ -825,7 +820,7 @@ daemonStreamHandleRead(virNetServerClient *client,
daemonClientStream *stream) daemonClientStream *stream)
{ {
virNetMessage *msg = NULL; virNetMessage *msg = NULL;
virNetMessageError rerr; virNetMessageError rerr = { 0 };
char *buffer; char *buffer;
size_t bufferLen = VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX; size_t bufferLen = VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX;
int ret = -1; int ret = -1;
@ -848,8 +843,6 @@ daemonStreamHandleRead(virNetServerClient *client,
if (!stream->tx) if (!stream->tx)
return 0; return 0;
memset(&rerr, 0, sizeof(rerr));
buffer = g_new0(char, bufferLen); buffer = g_new0(char, bufferLen);
if (!(msg = virNetMessageNew(false))) if (!(msg = virNetMessageNew(false)))

View File

@ -1184,10 +1184,9 @@ doRemoteOpen(virConnectPtr conn,
/* Now try and find out what URI the daemon used */ /* Now try and find out what URI the daemon used */
if (conn->uri == NULL) { if (conn->uri == NULL) {
remote_connect_get_uri_ret uriret; remote_connect_get_uri_ret uriret = { 0 };
VIR_DEBUG("Trying to query remote URI"); VIR_DEBUG("Trying to query remote URI");
memset(&uriret, 0, sizeof(uriret));
if (call(conn, priv, 0, if (call(conn, priv, 0,
REMOTE_PROC_CONNECT_GET_URI, REMOTE_PROC_CONNECT_GET_URI,
(xdrproc_t) xdr_void, (char *) NULL, (xdrproc_t) xdr_void, (char *) NULL,
@ -3725,9 +3724,9 @@ static int
remoteAuthSASL(virConnectPtr conn, struct private_data *priv, remoteAuthSASL(virConnectPtr conn, struct private_data *priv,
virConnectAuthPtr auth, const char *wantmech) virConnectAuthPtr auth, const char *wantmech)
{ {
remote_auth_sasl_init_ret iret; remote_auth_sasl_init_ret iret = { 0 };
remote_auth_sasl_start_args sargs = {0}; remote_auth_sasl_start_args sargs = {0};
remote_auth_sasl_start_ret sret; remote_auth_sasl_start_ret sret = { 0 };
const char *clientout; const char *clientout;
char *serverin = NULL; char *serverin = NULL;
size_t clientoutlen, serverinlen; size_t clientoutlen, serverinlen;
@ -3739,9 +3738,7 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv,
const char *mechlist; const char *mechlist;
virNetSASLContext *saslCtxt; virNetSASLContext *saslCtxt;
virNetSASLSession *sasl = NULL; virNetSASLSession *sasl = NULL;
struct remoteAuthInteractState state; struct remoteAuthInteractState state = { 0 };
memset(&state, 0, sizeof(state));
VIR_DEBUG("Client initialize SASL authentication"); VIR_DEBUG("Client initialize SASL authentication");
@ -3787,7 +3784,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv,
goto cleanup; goto cleanup;
/* First call is to inquire about supported mechanisms in the server */ /* First call is to inquire about supported mechanisms in the server */
memset(&iret, 0, sizeof(iret));
if (call(conn, priv, 0, REMOTE_PROC_AUTH_SASL_INIT, if (call(conn, priv, 0, REMOTE_PROC_AUTH_SASL_INIT,
(xdrproc_t) xdr_void, (char *)NULL, (xdrproc_t) xdr_void, (char *)NULL,
(xdrproc_t) xdr_remote_auth_sasl_init_ret, (char *) &iret) != 0) (xdrproc_t) xdr_remote_auth_sasl_init_ret, (char *) &iret) != 0)
@ -3841,7 +3837,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv,
mech, clientoutlen, clientout); mech, clientoutlen, clientout);
/* Now send the initial auth data to the server */ /* Now send the initial auth data to the server */
memset(&sret, 0, sizeof(sret));
if (call(conn, priv, 0, REMOTE_PROC_AUTH_SASL_START, if (call(conn, priv, 0, REMOTE_PROC_AUTH_SASL_START,
(xdrproc_t) xdr_remote_auth_sasl_start_args, (char *) &sargs, (xdrproc_t) xdr_remote_auth_sasl_start_args, (char *) &sargs,
(xdrproc_t) xdr_remote_auth_sasl_start_ret, (char *) &sret) != 0) (xdrproc_t) xdr_remote_auth_sasl_start_ret, (char *) &sret) != 0)

View File

@ -116,11 +116,9 @@ static int
virNetClientProgramDispatchError(virNetClientProgram *prog G_GNUC_UNUSED, virNetClientProgramDispatchError(virNetClientProgram *prog G_GNUC_UNUSED,
virNetMessage *msg) virNetMessage *msg)
{ {
virNetMessageError err; virNetMessageError err = { 0 };
int ret = -1; int ret = -1;
memset(&err, 0, sizeof(err));
if (virNetMessageDecodePayload(msg, (xdrproc_t)xdr_virNetMessageError, &err) < 0) if (virNetMessageDecodePayload(msg, (xdrproc_t)xdr_virNetMessageError, &err) < 0)
goto cleanup; goto cleanup;

View File

@ -261,7 +261,7 @@ void virNetClientStreamSetClosed(virNetClientStream *st,
int virNetClientStreamSetError(virNetClientStream *st, int virNetClientStreamSetError(virNetClientStream *st,
virNetMessage *msg) virNetMessage *msg)
{ {
virNetMessageError err; virNetMessageError err = { 0 };
int ret = -1; int ret = -1;
virObjectLock(st); virObjectLock(st);
@ -270,7 +270,6 @@ int virNetClientStreamSetError(virNetClientStream *st,
VIR_DEBUG("Overwriting existing stream error %s", NULLSTR(st->err.message)); VIR_DEBUG("Overwriting existing stream error %s", NULLSTR(st->err.message));
virResetError(&st->err); virResetError(&st->err);
memset(&err, 0, sizeof(err));
if (virNetMessageDecodePayload(msg, (xdrproc_t)xdr_virNetMessageError, &err) < 0) if (virNetMessageDecodePayload(msg, (xdrproc_t)xdr_virNetMessageError, &err) < 0)
goto cleanup; goto cleanup;
@ -444,13 +443,12 @@ virNetClientStreamHandleHole(virNetClient *client,
virNetClientStream *st) virNetClientStream *st)
{ {
virNetMessage *msg; virNetMessage *msg;
virNetStreamHole data; virNetStreamHole data = { 0 };
int ret = -1; int ret = -1;
VIR_DEBUG("client=%p st=%p", client, st); VIR_DEBUG("client=%p st=%p", client, st);
msg = st->rx; msg = st->rx;
memset(&data, 0, sizeof(data));
/* We should not be called unless there's VIR_NET_STREAM_HOLE /* We should not be called unless there's VIR_NET_STREAM_HOLE
* message at the head of the list. But doesn't hurt to check */ * message at the head of the list. But doesn't hurt to check */
@ -634,7 +632,7 @@ virNetClientStreamSendHole(virNetClientStream *st,
unsigned int flags) unsigned int flags)
{ {
virNetMessage *msg = NULL; virNetMessage *msg = NULL;
virNetStreamHole data; virNetStreamHole data = { 0 };
int ret = -1; int ret = -1;
VIR_DEBUG("st=%p length=%llu", st, length); VIR_DEBUG("st=%p length=%llu", st, length);
@ -645,7 +643,6 @@ virNetClientStreamSendHole(virNetClientStream *st,
return -1; return -1;
} }
memset(&data, 0, sizeof(data));
data.length = length; data.length = length;
data.flags = flags; data.flags = flags;

View File

@ -692,7 +692,7 @@ virNetDaemonAddSignalHandler(virNetDaemon *dmn,
void *opaque) void *opaque)
{ {
g_autofree virNetDaemonSignal *sigdata = NULL; g_autofree virNetDaemonSignal *sigdata = NULL;
struct sigaction sig_action; struct sigaction sig_action = { 0 };
VIR_LOCK_GUARD lock = virObjectLockGuard(dmn); VIR_LOCK_GUARD lock = virObjectLockGuard(dmn);
if (virNetDaemonSignalSetup(dmn) < 0) if (virNetDaemonSignalSetup(dmn) < 0)
@ -706,7 +706,6 @@ virNetDaemonAddSignalHandler(virNetDaemon *dmn,
sigdata->func = func; sigdata->func = func;
sigdata->opaque = opaque; sigdata->opaque = opaque;
memset(&sig_action, 0, sizeof(sig_action));
sig_action.sa_sigaction = virNetDaemonSignalHandler; sig_action.sa_sigaction = virNetDaemonSignalHandler;
sig_action.sa_flags = SA_SIGINFO; sig_action.sa_flags = SA_SIGINFO;
sigemptyset(&sig_action.sa_mask); sigemptyset(&sig_action.sa_mask);

View File

@ -331,7 +331,7 @@ int virNetSASLSessionSecProps(virNetSASLSession *sasl,
int maxSSF, int maxSSF,
bool allowAnonymous) bool allowAnonymous)
{ {
sasl_security_properties_t secprops; sasl_security_properties_t secprops = { 0 };
int err; int err;
int ret = -1; int ret = -1;
@ -339,7 +339,6 @@ int virNetSASLSessionSecProps(virNetSASLSession *sasl,
minSSF, maxSSF, allowAnonymous, sasl->maxbufsize); minSSF, maxSSF, allowAnonymous, sasl->maxbufsize);
virObjectLock(sasl); virObjectLock(sasl);
memset(&secprops, 0, sizeof(secprops));
secprops.min_ssf = minSSF; secprops.min_ssf = minSSF;
secprops.max_ssf = maxSSF; secprops.max_ssf = maxSSF;

View File

@ -229,12 +229,11 @@ int virNetServerProgramUnknownError(virNetServerClient *client,
virNetMessage *msg, virNetMessage *msg,
struct virNetMessageHeader *req) struct virNetMessageHeader *req)
{ {
virNetMessageError rerr; virNetMessageError rerr = { 0 };
virReportError(VIR_ERR_RPC, virReportError(VIR_ERR_RPC,
_("Cannot find program %1$d version %2$d"), req->prog, req->vers); _("Cannot find program %1$d version %2$d"), req->prog, req->vers);
memset(&rerr, 0, sizeof(rerr));
return virNetServerProgramSendError(req->prog, return virNetServerProgramSendError(req->prog,
req->vers, req->vers,
client, client,
@ -273,9 +272,7 @@ int virNetServerProgramDispatch(virNetServerProgram *prog,
virNetMessage *msg) virNetMessage *msg)
{ {
int ret = -1; int ret = -1;
virNetMessageError rerr; virNetMessageError rerr = { 0 };
memset(&rerr, 0, sizeof(rerr));
VIR_DEBUG("prog=%d ver=%d type=%d status=%d serial=%u proc=%d", VIR_DEBUG("prog=%d ver=%d type=%d status=%d serial=%u proc=%d",
msg->header.prog, msg->header.vers, msg->header.type, msg->header.prog, msg->header.vers, msg->header.type,
@ -369,12 +366,10 @@ virNetServerProgramDispatchCall(virNetServerProgram *prog,
g_autofree char *ret = NULL; g_autofree char *ret = NULL;
int rv = -1; int rv = -1;
virNetServerProgramProc *dispatcher = NULL; virNetServerProgramProc *dispatcher = NULL;
virNetMessageError rerr; virNetMessageError rerr = { 0 };
size_t i; size_t i;
g_autoptr(virIdentity) identity = NULL; g_autoptr(virIdentity) identity = NULL;
memset(&rerr, 0, sizeof(rerr));
if (msg->header.status != VIR_NET_OK) { if (msg->header.status != VIR_NET_OK) {
virReportError(VIR_ERR_RPC, virReportError(VIR_ERR_RPC,
_("Unexpected message status %1$u"), _("Unexpected message status %1$u"),
@ -533,11 +528,10 @@ int virNetServerProgramSendStreamHole(virNetServerProgram *prog,
long long length, long long length,
unsigned int flags) unsigned int flags)
{ {
virNetStreamHole data; virNetStreamHole data = { 0 };
VIR_DEBUG("client=%p msg=%p length=%lld", client, msg, length); VIR_DEBUG("client=%p msg=%p length=%lld", client, msg, length);
memset(&data, 0, sizeof(data));
data.length = length; data.length = length;
data.flags = flags; data.flags = flags;

View File

@ -143,11 +143,10 @@ virNetSocketCheckProtocolByLookup(const char *address,
int family, int family,
bool *hasFamily) bool *hasFamily)
{ {
struct addrinfo hints; struct addrinfo hints = { 0 };
struct addrinfo *ai = NULL; struct addrinfo *ai = NULL;
int gaierr; int gaierr;
memset(&hints, 0, sizeof(hints));
hints.ai_family = family; hints.ai_family = family;
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
@ -313,7 +312,7 @@ int virNetSocketNewListenTCP(const char *nodename,
virNetSocket **socks = NULL; virNetSocket **socks = NULL;
size_t nsocks = 0; size_t nsocks = 0;
struct addrinfo *ai = NULL; struct addrinfo *ai = NULL;
struct addrinfo hints; struct addrinfo hints = { 0 };
int fd = -1; int fd = -1;
size_t i; size_t i;
int socketErrno = 0; int socketErrno = 0;
@ -326,7 +325,6 @@ int virNetSocketNewListenTCP(const char *nodename,
*retsocks = NULL; *retsocks = NULL;
*nretsocks = 0; *nretsocks = 0;
memset(&hints, 0, sizeof(hints));
hints.ai_family = family; hints.ai_family = family;
hints.ai_flags = AI_PASSIVE; hints.ai_flags = AI_PASSIVE;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
@ -353,9 +351,7 @@ int virNetSocketNewListenTCP(const char *nodename,
runp = ai; runp = ai;
while (runp) { while (runp) {
virSocketAddr addr; virSocketAddr addr = { 0 };
memset(&addr, 0, sizeof(addr));
if ((fd = socket(runp->ai_family, runp->ai_socktype, if ((fd = socket(runp->ai_family, runp->ai_socktype,
runp->ai_protocol)) < 0) { runp->ai_protocol)) < 0) {
@ -477,14 +473,12 @@ int virNetSocketNewListenUNIX(const char *path,
gid_t grp, gid_t grp,
virNetSocket **retsock) virNetSocket **retsock)
{ {
virSocketAddr addr; virSocketAddr addr = { 0 };
mode_t oldmask; mode_t oldmask;
int fd; int fd;
*retsock = NULL; *retsock = NULL;
memset(&addr, 0, sizeof(addr));
addr.len = sizeof(addr.data.un); addr.len = sizeof(addr.data.un);
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
@ -553,11 +547,9 @@ int virNetSocketNewListenFD(int fd,
bool unlinkUNIX, bool unlinkUNIX,
virNetSocket **retsock) virNetSocket **retsock)
{ {
virSocketAddr addr; virSocketAddr addr = { 0 };
*retsock = NULL; *retsock = NULL;
memset(&addr, 0, sizeof(addr));
addr.len = sizeof(addr.data); addr.len = sizeof(addr.data);
if (getsockname(fd, &addr.data.sa, &addr.len) < 0) { if (getsockname(fd, &addr.data.sa, &addr.len) < 0) {
virReportSystemError(errno, "%s", _("Unable to get local socket name")); virReportSystemError(errno, "%s", _("Unable to get local socket name"));
@ -577,20 +569,16 @@ int virNetSocketNewConnectTCP(const char *nodename,
virNetSocket **retsock) virNetSocket **retsock)
{ {
struct addrinfo *ai = NULL; struct addrinfo *ai = NULL;
struct addrinfo hints; struct addrinfo hints = { 0 };
int fd = -1; int fd = -1;
virSocketAddr localAddr; virSocketAddr localAddr = { 0 };
virSocketAddr remoteAddr; virSocketAddr remoteAddr = { 0 };
struct addrinfo *runp; struct addrinfo *runp;
int savedErrno = ENOENT; int savedErrno = ENOENT;
int e; int e;
*retsock = NULL; *retsock = NULL;
memset(&localAddr, 0, sizeof(localAddr));
memset(&remoteAddr, 0, sizeof(remoteAddr));
memset(&hints, 0, sizeof(hints));
hints.ai_family = family; hints.ai_family = family;
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED; hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
@ -666,17 +654,14 @@ int virNetSocketNewConnectUNIX(const char *path,
VIR_AUTOCLOSE lockfd = -1; VIR_AUTOCLOSE lockfd = -1;
int fd = -1; int fd = -1;
int retries = 500; int retries = 500;
virSocketAddr localAddr; virSocketAddr localAddr = { 0 };
virSocketAddr remoteAddr; virSocketAddr remoteAddr = { 0 };
g_autofree char *rundir = NULL; g_autofree char *rundir = NULL;
int ret = -1; int ret = -1;
bool daemonLaunched = false; bool daemonLaunched = false;
VIR_DEBUG("path=%s spawnDaemonPath=%s", path, NULLSTR(spawnDaemonPath)); VIR_DEBUG("path=%s spawnDaemonPath=%s", path, NULLSTR(spawnDaemonPath));
memset(&localAddr, 0, sizeof(localAddr));
memset(&remoteAddr, 0, sizeof(remoteAddr));
remoteAddr.len = sizeof(remoteAddr.data.un); remoteAddr.len = sizeof(remoteAddr.data.un);
if (spawnDaemonPath) { if (spawnDaemonPath) {
@ -1168,8 +1153,8 @@ int virNetSocketNewConnectSockFD(int sockfd,
virNetSocket *virNetSocketNewPostExecRestart(virJSONValue *object) virNetSocket *virNetSocketNewPostExecRestart(virJSONValue *object)
{ {
virSocketAddr localAddr; virSocketAddr localAddr = { 0 };
virSocketAddr remoteAddr; virSocketAddr remoteAddr = { 0 };
int fd, thepid, errfd; int fd, thepid, errfd;
bool isClient; bool isClient;
bool unlinkUNIX; bool unlinkUNIX;
@ -1201,9 +1186,6 @@ virNetSocket *virNetSocketNewPostExecRestart(virJSONValue *object)
if (virJSONValueObjectGetBoolean(object, "unlinkUNIX", &unlinkUNIX) < 0) if (virJSONValueObjectGetBoolean(object, "unlinkUNIX", &unlinkUNIX) < 0)
unlinkUNIX = !isClient; unlinkUNIX = !isClient;
memset(&localAddr, 0, sizeof(localAddr));
memset(&remoteAddr, 0, sizeof(remoteAddr));
remoteAddr.len = sizeof(remoteAddr.data.stor); remoteAddr.len = sizeof(remoteAddr.data.stor);
if (getsockname(fd, &remoteAddr.data.sa, &remoteAddr.len) < 0) { if (getsockname(fd, &remoteAddr.data.sa, &remoteAddr.len) < 0) {
virReportSystemError(errno, "%s", _("Unable to get peer socket name")); virReportSystemError(errno, "%s", _("Unable to get peer socket name"));
@ -2059,17 +2041,14 @@ int virNetSocketListen(virNetSocket *sock, int backlog)
int virNetSocketAccept(virNetSocket *sock, virNetSocket **clientsock) int virNetSocketAccept(virNetSocket *sock, virNetSocket **clientsock)
{ {
int fd = -1; int fd = -1;
virSocketAddr localAddr; virSocketAddr localAddr = { 0 };
virSocketAddr remoteAddr; virSocketAddr remoteAddr = { 0 };
int ret = -1; int ret = -1;
virObjectLock(sock); virObjectLock(sock);
*clientsock = NULL; *clientsock = NULL;
memset(&localAddr, 0, sizeof(localAddr));
memset(&remoteAddr, 0, sizeof(remoteAddr));
remoteAddr.len = sizeof(remoteAddr.data.stor); remoteAddr.len = sizeof(remoteAddr.data.stor);
if ((fd = accept(sock->fd, &remoteAddr.data.sa, &remoteAddr.len)) < 0) { if ((fd = accept(sock->fd, &remoteAddr.data.sa, &remoteAddr.len)) < 0) {
if (errno == ECONNABORTED || if (errno == ECONNABORTED ||

View File

@ -559,7 +559,7 @@ static int
virNetSSHAuthenticatePrivkey(virNetSSHSession *sess, virNetSSHAuthenticatePrivkey(virNetSSHSession *sess,
virNetSSHAuthMethod *priv) virNetSSHAuthMethod *priv)
{ {
virConnectCredential retr_passphrase; virConnectCredential retr_passphrase = { 0 };
size_t i; size_t i;
char *errmsg; char *errmsg;
int ret; int ret;
@ -594,7 +594,6 @@ virNetSSHAuthenticatePrivkey(virNetSSHSession *sess,
return -1; return -1;
} }
memset(&retr_passphrase, 0, sizeof(virConnectCredential));
retr_passphrase.type = -1; retr_passphrase.type = -1;
for (i = 0; i < sess->cred->ncredtype; i++) { for (i = 0; i < sess->cred->ncredtype; i++) {

View File

@ -186,11 +186,9 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
*/ */
for (i = 0; i < nextents; i++) { for (i = 0; i < nextents; i++) {
g_autofree char *offset_str = NULL; g_autofree char *offset_str = NULL;
virStorageVolSourceExtent extent; virStorageVolSourceExtent extent = { 0 };
size_t j = (i * 2) + 1; size_t j = (i * 2) + 1;
memset(&extent, 0, sizeof(extent));
offset_str = g_match_info_fetch(info, j + 1); offset_str = g_match_info_fetch(info, j + 1);
if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) { if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) {
@ -503,13 +501,12 @@ static char *
virStorageBackendLogicalFindPoolSources(const char *srcSpec G_GNUC_UNUSED, virStorageBackendLogicalFindPoolSources(const char *srcSpec G_GNUC_UNUSED,
unsigned int flags) unsigned int flags)
{ {
virStoragePoolSourceList sourceList; virStoragePoolSourceList sourceList = { 0 };
size_t i; size_t i;
char *retval = NULL; char *retval = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&sourceList, 0, sizeof(sourceList));
sourceList.type = VIR_STORAGE_POOL_LOGICAL; sourceList.type = VIR_STORAGE_POOL_LOGICAL;
if (virStorageBackendLogicalGetPoolSources(&sourceList) < 0) if (virStorageBackendLogicalGetPoolSources(&sourceList) < 0)
@ -549,13 +546,12 @@ static bool
virStorageBackendLogicalMatchPoolSource(virStoragePoolObj *pool) virStorageBackendLogicalMatchPoolSource(virStoragePoolObj *pool)
{ {
virStoragePoolDef *def = virStoragePoolObjGetDef(pool); virStoragePoolDef *def = virStoragePoolObjGetDef(pool);
virStoragePoolSourceList sourceList; virStoragePoolSourceList sourceList = { 0 };
virStoragePoolSource *thisSource = NULL; virStoragePoolSource *thisSource = NULL;
size_t i, j; size_t i, j;
int matchcount = 0; int matchcount = 0;
bool ret = false; bool ret = false;
memset(&sourceList, 0, sizeof(sourceList));
sourceList.type = VIR_STORAGE_POOL_LOGICAL; sourceList.type = VIR_STORAGE_POOL_LOGICAL;
if (virStorageBackendLogicalGetPoolSources(&sourceList) < 0) if (virStorageBackendLogicalGetPoolSources(&sourceList) < 0)

View File

@ -111,13 +111,12 @@ virArpTableGet(void)
if (tb[NDA_DST]) { if (tb[NDA_DST]) {
g_autofree char *ipstr = NULL; g_autofree char *ipstr = NULL;
virSocketAddr virAddr; virSocketAddr virAddr = { 0 };
VIR_REALLOC_N(table->t, num + 1); VIR_REALLOC_N(table->t, num + 1);
table->n = num + 1; table->n = num + 1;
addr = RTA_DATA(tb[NDA_DST]); addr = RTA_DATA(tb[NDA_DST]);
memset(&virAddr, 0, sizeof(virAddr));
virAddr.len = sizeof(virAddr.data.inet4); virAddr.len = sizeof(virAddr.data.inet4);
virAddr.data.inet4.sin_family = AF_INET; virAddr.data.inet4.sin_family = AF_INET;
virAddr.data.inet4.sin_addr = *(struct in_addr *)addr; virAddr.data.inet4.sin_addr = *(struct in_addr *)addr;

View File

@ -135,7 +135,7 @@ virAuthGetUsernamePath(const char *path,
const char *hostname) const char *hostname)
{ {
unsigned int ncred; unsigned int ncred;
virConnectCredential cred; virConnectCredential cred = { 0 };
g_autofree char *prompt = NULL; g_autofree char *prompt = NULL;
char *ret = NULL; char *ret = NULL;
@ -150,8 +150,6 @@ virAuthGetUsernamePath(const char *path,
return NULL; return NULL;
} }
memset(&cred, 0, sizeof(virConnectCredential));
if (defaultUsername != NULL) { if (defaultUsername != NULL) {
prompt = g_strdup_printf(_("Enter username for %1$s [%2$s]"), hostname, prompt = g_strdup_printf(_("Enter username for %1$s [%2$s]"), hostname,
defaultUsername); defaultUsername);

View File

@ -35,9 +35,7 @@ virBPFCreateMap(unsigned int mapType,
unsigned int valSize, unsigned int valSize,
unsigned int maxEntries) unsigned int maxEntries)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.map_type = mapType; attr.map_type = mapType;
attr.key_size = keySize; attr.key_size = keySize;
@ -57,12 +55,10 @@ virBPFLoadProg(struct bpf_insn *insns,
{ {
g_autofree char *logbuf = NULL; g_autofree char *logbuf = NULL;
int progfd = -1; int progfd = -1;
union bpf_attr attr; union bpf_attr attr = { 0 };
logbuf = g_new0(char, LOG_BUF_SIZE); logbuf = g_new0(char, LOG_BUF_SIZE);
memset(&attr, 0, sizeof(attr));
attr.prog_type = progType; attr.prog_type = progType;
attr.insn_cnt = insnCnt; attr.insn_cnt = insnCnt;
attr.insns = (uintptr_t)insns; attr.insns = (uintptr_t)insns;
@ -85,9 +81,7 @@ virBPFAttachProg(int progfd,
int targetfd, int targetfd,
int attachType) int attachType)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.target_fd = targetfd; attr.target_fd = targetfd;
attr.attach_bpf_fd = progfd; attr.attach_bpf_fd = progfd;
@ -102,9 +96,7 @@ virBPFDetachProg(int progfd,
int targetfd, int targetfd,
int attachType) int attachType)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.target_fd = targetfd; attr.target_fd = targetfd;
attr.attach_bpf_fd = progfd; attr.attach_bpf_fd = progfd;
@ -121,11 +113,9 @@ virBPFQueryProg(int targetfd,
unsigned int *progcnt, unsigned int *progcnt,
void *progids) void *progids)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
int rc; int rc;
memset(&attr, 0, sizeof(attr));
attr.query.target_fd = targetfd; attr.query.target_fd = targetfd;
attr.query.attach_type = attachType; attr.query.attach_type = attachType;
attr.query.prog_cnt = maxprogids; attr.query.prog_cnt = maxprogids;
@ -143,9 +133,7 @@ virBPFQueryProg(int targetfd,
int int
virBPFGetProg(unsigned int id) virBPFGetProg(unsigned int id)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.prog_id = id; attr.prog_id = id;
@ -158,11 +146,9 @@ virBPFGetProgInfo(int progfd,
struct bpf_prog_info *info, struct bpf_prog_info *info,
unsigned int **mapIDs) unsigned int **mapIDs)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
int rc; int rc;
memset(&attr, 0, sizeof(attr));
attr.info.bpf_fd = progfd; attr.info.bpf_fd = progfd;
attr.info.info_len = sizeof(struct bpf_prog_info); attr.info.info_len = sizeof(struct bpf_prog_info);
attr.info.info = (uintptr_t)info; attr.info.info = (uintptr_t)info;
@ -200,9 +186,7 @@ virBPFGetProgInfo(int progfd,
int int
virBPFGetMap(unsigned int id) virBPFGetMap(unsigned int id)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.map_id = id; attr.map_id = id;
@ -214,9 +198,7 @@ int
virBPFGetMapInfo(int mapfd, virBPFGetMapInfo(int mapfd,
struct bpf_map_info *info) struct bpf_map_info *info)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.info.bpf_fd = mapfd; attr.info.bpf_fd = mapfd;
attr.info.info_len = sizeof(struct bpf_map_info); attr.info.info_len = sizeof(struct bpf_map_info);
@ -231,9 +213,7 @@ virBPFLookupElem(int mapfd,
void *key, void *key,
void *val) void *val)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.map_fd = mapfd; attr.map_fd = mapfd;
attr.key = (uintptr_t)key; attr.key = (uintptr_t)key;
@ -248,9 +228,7 @@ virBPFGetNextElem(int mapfd,
void *key, void *key,
void *nextKey) void *nextKey)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.map_fd = mapfd; attr.map_fd = mapfd;
attr.key = (uintptr_t)key; attr.key = (uintptr_t)key;
@ -265,9 +243,7 @@ virBPFUpdateElem(int mapfd,
void *key, void *key,
void *val) void *val)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.map_fd = mapfd; attr.map_fd = mapfd;
attr.key = (uintptr_t)key; attr.key = (uintptr_t)key;
@ -281,9 +257,7 @@ int
virBPFDeleteElem(int mapfd, virBPFDeleteElem(int mapfd,
void *key) void *key)
{ {
union bpf_attr attr; union bpf_attr attr = { 0 };
memset(&attr, 0, sizeof(attr));
attr.map_fd = mapfd; attr.map_fd = mapfd;
attr.key = (uintptr_t)key; attr.key = (uintptr_t)key;

View File

@ -128,12 +128,10 @@ static int
virDMOpen(void) virDMOpen(void)
{ {
VIR_AUTOCLOSE controlFD = -1; VIR_AUTOCLOSE controlFD = -1;
struct dm_ioctl dm; struct dm_ioctl dm = { 0 };
g_autofree char *tmp = NULL; g_autofree char *tmp = NULL;
int ret; int ret;
memset(&dm, 0, sizeof(dm));
if ((controlFD = open(CONTROL_PATH, O_RDWR)) < 0) { if ((controlFD = open(CONTROL_PATH, O_RDWR)) < 0) {
/* We can't talk to devmapper. Produce a warning and let /* We can't talk to devmapper. Produce a warning and let
* the caller decide what to do next. */ * the caller decide what to do next. */
@ -223,12 +221,10 @@ virDevMapperGetTargetsImpl(int controlFD,
{ {
g_autofree char *sanitizedPath = NULL; g_autofree char *sanitizedPath = NULL;
g_autofree char *buf = NULL; g_autofree char *buf = NULL;
struct dm_ioctl dm; struct dm_ioctl dm = { 0 };
struct dm_target_deps *deps = NULL; struct dm_target_deps *deps = NULL;
size_t i; size_t i;
memset(&dm, 0, sizeof(dm));
if (ttl == 0) { if (ttl == 0) {
errno = ELOOP; errno = ELOOP;
return -1; return -1;

View File

@ -1192,7 +1192,7 @@ int virFDStreamConnectUNIX(virStreamPtr st,
const char *path, const char *path,
bool abstract) bool abstract)
{ {
struct sockaddr_un sa; struct sockaddr_un sa = { 0 };
virTimeBackOffVar timeout; virTimeBackOffVar timeout;
VIR_AUTOCLOSE fd = -1; VIR_AUTOCLOSE fd = -1;
int ret; int ret;
@ -1203,7 +1203,6 @@ int virFDStreamConnectUNIX(virStreamPtr st,
return -1; return -1;
} }
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX; sa.sun_family = AF_UNIX;
if (abstract) { if (abstract) {
if (virStrcpy(sa.sun_path+1, path, sizeof(sa.sun_path)-1) < 0) if (virStrcpy(sa.sun_path+1, path, sizeof(sa.sun_path)-1) < 0)

View File

@ -876,14 +876,13 @@ int virFileLoopDeviceAssociate(const char *file,
{ {
int lofd = -1; int lofd = -1;
int fsfd = -1; int fsfd = -1;
struct loop_info64 lo; struct loop_info64 lo = { 0 };
g_autofree char *loname = NULL; g_autofree char *loname = NULL;
int ret = -1; int ret = -1;
if ((lofd = virFileLoopDeviceOpen(&loname)) < 0) if ((lofd = virFileLoopDeviceOpen(&loname)) < 0)
return -1; return -1;
memset(&lo, 0, sizeof(lo));
lo.lo_flags = LO_FLAGS_AUTOCLEAR; lo.lo_flags = LO_FLAGS_AUTOCLEAR;
/* Set backing file name for LOOP_GET_STATUS64 queries */ /* Set backing file name for LOOP_GET_STATUS64 queries */

View File

@ -124,14 +124,12 @@ int
virInitctlSetRunLevel(const char *fifo, virInitctlSetRunLevel(const char *fifo,
virInitctlRunLevel level) virInitctlRunLevel level)
{ {
struct virInitctlRequest req; struct virInitctlRequest req = { 0 };
int fd = -1; int fd = -1;
int ret = -1; int ret = -1;
const int open_flags = O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY; const int open_flags = O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY;
size_t i = 0; size_t i = 0;
memset(&req, 0, sizeof(req));
req.magic = VIR_INITCTL_MAGIC; req.magic = VIR_INITCTL_MAGIC;
req.sleeptime = 0; req.sleeptime = 0;
req.cmd = VIR_INITCTL_CMD_RUNLVL; req.cmd = VIR_INITCTL_CMD_RUNLVL;

View File

@ -394,7 +394,7 @@ virISCSIScanTargetsInternal(const char *portal,
"^\\s*(\\S+)\\s+(\\S+)\\s*$" "^\\s*(\\S+)\\s+(\\S+)\\s*$"
}; };
int vars[] = { 2 }; int vars[] = { 2 };
struct virISCSITargetList list; struct virISCSITargetList list = { 0 };
size_t i; size_t i;
g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM, g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM,
"--mode", "discovery", "--mode", "discovery",
@ -414,8 +414,6 @@ virISCSIScanTargetsInternal(const char *portal,
NULL); NULL);
} }
memset(&list, 0, sizeof(list));
if (virCommandRunRegex(cmd, if (virCommandRunRegex(cmd,
1, 1,
regexes, regexes,

View File

@ -897,12 +897,12 @@ virLogOutputToJournald(virLogSource *source,
{ {
int buffd = -1; int buffd = -1;
int journalfd = (intptr_t) data; int journalfd = (intptr_t) data;
struct msghdr mh; struct msghdr mh = { 0 };
struct sockaddr_un sa; struct sockaddr_un sa = { 0 };
union { union {
struct cmsghdr cmsghdr; struct cmsghdr cmsghdr;
uint8_t buf[CMSG_SPACE(sizeof(int))]; uint8_t buf[CMSG_SPACE(sizeof(int))];
} control; } control = { 0 };
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
/* We use /dev/shm instead of /tmp here, since we want this to /* We use /dev/shm instead of /tmp here, since we want this to
* be a tmpfs, and one that is available from early boot on * be a tmpfs, and one that is available from early boot on
@ -950,12 +950,10 @@ virLogOutputToJournald(virLogSource *source,
} }
} }
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX; sa.sun_family = AF_UNIX;
if (virStrcpyStatic(sa.sun_path, "/run/systemd/journal/socket") < 0) if (virStrcpyStatic(sa.sun_path, "/run/systemd/journal/socket") < 0)
return; return;
memset(&mh, 0, sizeof(mh));
mh.msg_name = &sa; mh.msg_name = &sa;
mh.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(sa.sun_path); mh.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(sa.sun_path);
mh.msg_iov = iov; mh.msg_iov = iov;
@ -983,7 +981,6 @@ virLogOutputToJournald(virLogSource *source,
mh.msg_iov = NULL; mh.msg_iov = NULL;
mh.msg_iovlen = 0; mh.msg_iovlen = 0;
memset(&control, 0, sizeof(control));
mh.msg_control = &control; mh.msg_control = &control;
mh.msg_controllen = sizeof(control); mh.msg_controllen = sizeof(control);

View File

@ -812,9 +812,7 @@ virNetDevGetRcvAllMulti(const char *ifname,
#if defined(WITH_IF_INDEXTONAME) #if defined(WITH_IF_INDEXTONAME)
char *virNetDevGetName(int ifindex) char *virNetDevGetName(int ifindex)
{ {
char name[IFNAMSIZ]; char name[IFNAMSIZ] = { 0 };
memset(&name, 0, sizeof(name));
if (!if_indextoname(ifindex, name)) { if (!if_indextoname(ifindex, name)) {
virReportSystemError(errno, virReportSystemError(errno,
@ -847,7 +845,7 @@ char *virNetDevGetName(int ifindex)
#if defined(SIOCGIFINDEX) && defined(WITH_STRUCT_IFREQ) #if defined(SIOCGIFINDEX) && defined(WITH_STRUCT_IFREQ)
int virNetDevGetIndex(const char *ifname, int *ifindex) int virNetDevGetIndex(const char *ifname, int *ifindex)
{ {
struct ifreq ifreq; struct ifreq ifreq = { 0 };
VIR_AUTOCLOSE fd = socket(VIR_NETDEV_FAMILY, SOCK_DGRAM, 0); VIR_AUTOCLOSE fd = socket(VIR_NETDEV_FAMILY, SOCK_DGRAM, 0);
if (fd < 0) { if (fd < 0) {
@ -856,8 +854,6 @@ int virNetDevGetIndex(const char *ifname, int *ifindex)
return -1; return -1;
} }
memset(&ifreq, 0, sizeof(ifreq));
if (virStrcpyStatic(ifreq.ifr_name, ifname) < 0) { if (virStrcpyStatic(ifreq.ifr_name, ifname) < 0) {
virReportSystemError(ERANGE, virReportSystemError(ERANGE,
_("invalid interface name %1$s"), _("invalid interface name %1$s"),

View File

@ -57,11 +57,9 @@ static int virNetDevBridgeCmd(const char *brname,
void *arg, void *arg,
size_t argsize) size_t argsize)
{ {
struct ifdrv ifd; struct ifdrv ifd = { 0 };
VIR_AUTOCLOSE s = -1; VIR_AUTOCLOSE s = -1;
memset(&ifd, 0, sizeof(ifd));
if ((s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) { if ((s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
virReportSystemError(errno, "%s", virReportSystemError(errno, "%s",
_("Cannot open network interface control socket")); _("Cannot open network interface control socket"));
@ -621,9 +619,8 @@ int virNetDevBridgeAddPort(const char *brname,
int virNetDevBridgeAddPort(const char *brname, int virNetDevBridgeAddPort(const char *brname,
const char *ifname) const char *ifname)
{ {
struct ifbreq req; struct ifbreq req = { 0 };
memset(&req, 0, sizeof(req));
if (virStrcpyStatic(req.ifbr_ifsname, ifname) < 0) { if (virStrcpyStatic(req.ifbr_ifsname, ifname) < 0) {
virReportSystemError(ERANGE, virReportSystemError(ERANGE,
_("Network interface name '%1$s' is too long"), _("Network interface name '%1$s' is too long"),
@ -687,9 +684,8 @@ int virNetDevBridgeRemovePort(const char *brname,
int virNetDevBridgeRemovePort(const char *brname, int virNetDevBridgeRemovePort(const char *brname,
const char *ifname) const char *ifname)
{ {
struct ifbreq req; struct ifbreq req = { 0 };
memset(&req, 0, sizeof(req));
if (virStrcpyStatic(req.ifbr_ifsname, ifname) < 0) { if (virStrcpyStatic(req.ifbr_ifsname, ifname) < 0) {
virReportSystemError(ERANGE, virReportSystemError(ERANGE,
_("Network interface name '%1$s' is too long"), _("Network interface name '%1$s' is too long"),

View File

@ -84,7 +84,7 @@ virNetDevCreateNetlinkAddressMessage(int messageType,
virSocketAddr *peer) virSocketAddr *peer)
{ {
struct nl_msg *nlmsg = NULL; struct nl_msg *nlmsg = NULL;
struct ifaddrmsg ifa; struct ifaddrmsg ifa = { 0 };
unsigned int ifindex; unsigned int ifindex;
void *addrData = NULL; void *addrData = NULL;
void *peerData = NULL; void *peerData = NULL;
@ -110,8 +110,6 @@ virNetDevCreateNetlinkAddressMessage(int messageType,
nlmsg = virNetlinkMsgNew(messageType, nlmsg = virNetlinkMsgNew(messageType,
NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
memset(&ifa, 0, sizeof(ifa));
ifa.ifa_prefixlen = prefix; ifa.ifa_prefixlen = prefix;
ifa.ifa_family = VIR_SOCKET_ADDR_FAMILY(addr); ifa.ifa_family = VIR_SOCKET_ADDR_FAMILY(addr);
ifa.ifa_index = ifindex; ifa.ifa_index = ifindex;
@ -277,7 +275,7 @@ virNetDevIPRouteAdd(const char *ifname,
{ {
unsigned int recvbuflen; unsigned int recvbuflen;
unsigned int ifindex; unsigned int ifindex;
struct rtmsg rtmsg; struct rtmsg rtmsg = { 0 };
void *gatewayData = NULL; void *gatewayData = NULL;
void *addrData = NULL; void *addrData = NULL;
size_t addrDataLen; size_t addrDataLen;
@ -323,8 +321,6 @@ virNetDevIPRouteAdd(const char *ifname,
nlmsg = virNetlinkMsgNew(RTM_NEWROUTE, nlmsg = virNetlinkMsgNew(RTM_NEWROUTE,
NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
memset(&rtmsg, 0, sizeof(rtmsg));
rtmsg.rtm_family = VIR_SOCKET_ADDR_FAMILY(gateway); rtmsg.rtm_family = VIR_SOCKET_ADDR_FAMILY(gateway);
rtmsg.rtm_table = RT_TABLE_MAIN; rtmsg.rtm_table = RT_TABLE_MAIN;
rtmsg.rtm_scope = RT_SCOPE_UNIVERSE; rtmsg.rtm_scope = RT_SCOPE_UNIVERSE;

View File

@ -270,7 +270,7 @@ int virNetDevTapCreate(char **ifname,
int virNetDevTapDelete(const char *ifname, int virNetDevTapDelete(const char *ifname,
const char *tunpath) const char *tunpath)
{ {
struct ifreq try; struct ifreq try = { 0 };
int fd; int fd;
int ret = -1; int ret = -1;
@ -284,7 +284,6 @@ int virNetDevTapDelete(const char *ifname,
return -1; return -1;
} }
memset(&try, 0, sizeof(struct ifreq));
try.ifr_flags = IFF_TAP|IFF_NO_PI; try.ifr_flags = IFF_TAP|IFF_NO_PI;
if (virStrcpyStatic(try.ifr_name, ifname) < 0) { if (virStrcpyStatic(try.ifr_name, ifname) < 0) {

View File

@ -203,7 +203,7 @@ virPerfEventEnable(virPerf *perf,
virPerfEventType type, virPerfEventType type,
pid_t pid) pid_t pid)
{ {
struct perf_event_attr attr; struct perf_event_attr attr = { 0 };
struct virPerfEvent *event = &(perf->events[type]); struct virPerfEvent *event = &(perf->events[type]);
struct virPerfEventAttr *event_attr = &attrs[type]; struct virPerfEventAttr *event_attr = &attrs[type];
@ -233,7 +233,6 @@ virPerfEventEnable(virPerf *perf,
} }
} }
memset(&attr, 0, sizeof(attr));
attr.size = sizeof(attr); attr.size = sizeof(attr);
attr.inherit = 1; attr.inherit = 1;
attr.disabled = 1; attr.disabled = 1;

View File

@ -1539,13 +1539,12 @@ virProcessExitWithStatus(int status)
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
value = WEXITSTATUS(status); value = WEXITSTATUS(status);
} else if (WIFSIGNALED(status)) { } else if (WIFSIGNALED(status)) {
struct sigaction act; struct sigaction act = { 0 };
sigset_t sigs; sigset_t sigs;
if (sigemptyset(&sigs) == 0 && if (sigemptyset(&sigs) == 0 &&
sigaddset(&sigs, WTERMSIG(status)) == 0) sigaddset(&sigs, WTERMSIG(status)) == 0)
sigprocmask(SIG_UNBLOCK, &sigs, NULL); sigprocmask(SIG_UNBLOCK, &sigs, NULL);
memset(&act, 0, sizeof(act));
act.sa_handler = SIG_DFL; act.sa_handler = SIG_DFL;
sigfillset(&act.sa_mask); sigfillset(&act.sa_mask);
sigaction(WTERMSIG(status), &act, NULL); sigaction(WTERMSIG(status), &act, NULL);

View File

@ -389,12 +389,11 @@ virSocketSendFD(int sock, int fd)
{ {
char byte = 0; char byte = 0;
struct iovec iov; struct iovec iov;
struct msghdr msg; struct msghdr msg = { 0 };
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
char buf[CMSG_SPACE(sizeof(fd))]; char buf[CMSG_SPACE(sizeof(fd))];
/* send at least one char */ /* send at least one char */
memset(&msg, 0, sizeof(msg));
iov.iov_base = &byte; iov.iov_base = &byte;
iov.iov_len = 1; iov.iov_len = 1;
msg.msg_iov = &iov; msg.msg_iov = &iov;
@ -428,7 +427,7 @@ virSocketRecvFD(int sock, int fdflags)
{ {
char byte = 0; char byte = 0;
struct iovec iov; struct iovec iov;
struct msghdr msg; struct msghdr msg = { 0 };
int fd = -1; int fd = -1;
ssize_t len; ssize_t len;
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
@ -441,7 +440,6 @@ virSocketRecvFD(int sock, int fdflags)
} }
/* send at least one char */ /* send at least one char */
memset(&msg, 0, sizeof(msg));
iov.iov_base = &byte; iov.iov_base = &byte;
iov.iov_len = 1; iov.iov_len = 1;
msg.msg_iov = &iov; msg.msg_iov = &iov;

View File

@ -92,7 +92,7 @@ virSocketAddrParseInternal(struct addrinfo **res,
int ai_flags, int ai_flags,
bool reportError) bool reportError)
{ {
struct addrinfo hints; struct addrinfo hints = { 0 };
int err; int err;
if (val == NULL) { if (val == NULL) {
@ -101,7 +101,6 @@ virSocketAddrParseInternal(struct addrinfo **res,
return -1; return -1;
} }
memset(&hints, 0, sizeof(hints));
hints.ai_family = family; hints.ai_family = family;
hints.ai_flags = ai_flags; hints.ai_flags = ai_flags;
if ((err = getaddrinfo(val, NULL, &hints, res)) != 0) { if ((err = getaddrinfo(val, NULL, &hints, res)) != 0) {
@ -240,12 +239,10 @@ virSocketAddrParseIPv6(virSocketAddr *addr, const char *val)
int virSocketAddrResolveService(const char *service) int virSocketAddrResolveService(const char *service)
{ {
struct addrinfo *res, *tmp; struct addrinfo *res, *tmp;
struct addrinfo hints; struct addrinfo hints = { 0 };
int err; int err;
int port = -1; int port = -1;
memset(&hints, 0, sizeof(hints));
if ((err = getaddrinfo(NULL, service, &hints, &res)) != 0) { if ((err = getaddrinfo(NULL, service, &hints, &res)) != 0) {
virReportError(VIR_ERR_SYSTEM_ERROR, virReportError(VIR_ERR_SYSTEM_ERROR,
_("Cannot parse socket service '%1$s': %2$s"), _("Cannot parse socket service '%1$s': %2$s"),

View File

@ -201,12 +201,10 @@ virURIParse(const char *uri)
char * char *
virURIFormat(virURI *uri) virURIFormat(virURI *uri)
{ {
xmlURI xmluri; xmlURI xmluri = { 0 };
g_autofree char *tmpserver = NULL; g_autofree char *tmpserver = NULL;
char *ret; char *ret;
memset(&xmluri, 0, sizeof(xmluri));
xmluri.scheme = uri->scheme; xmluri.scheme = uri->scheme;
xmluri.server = uri->server; xmluri.server = uri->server;
xmluri.port = uri->port; xmluri.port = uri->port;

View File

@ -396,7 +396,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
struct _vboxDriver *data = pool->conn->privateData; struct _vboxDriver *data = pool->conn->privateData;
PRUnichar *hddFormatUtf16 = NULL; PRUnichar *hddFormatUtf16 = NULL;
PRUnichar *hddNameUtf16 = NULL; PRUnichar *hddNameUtf16 = NULL;
virStoragePoolDef poolDef; virStoragePoolDef poolDef = { 0 };
nsresult rc; nsresult rc;
vboxIID hddIID; vboxIID hddIID;
unsigned char uuid[VIR_UUID_BUFLEN]; unsigned char uuid[VIR_UUID_BUFLEN];
@ -424,7 +424,6 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
* so just assign it for now, change the behaviour * so just assign it for now, change the behaviour
* when vbox supports pools. * when vbox supports pools.
*/ */
memset(&poolDef, 0, sizeof(poolDef));
poolDef.type = VIR_STORAGE_POOL_DIR; poolDef.type = VIR_STORAGE_POOL_DIR;
if ((def = virStorageVolDefParse(&poolDef, xml, NULL, parseFlags)) == NULL) if ((def = virStorageVolDefParse(&poolDef, xml, NULL, parseFlags)) == NULL)
@ -720,8 +719,8 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
char *hddFormatUtf8 = NULL; char *hddFormatUtf8 = NULL;
PRUint64 hddLogicalSize = 0; PRUint64 hddLogicalSize = 0;
PRUint64 hddActualSize = 0; PRUint64 hddActualSize = 0;
virStoragePoolDef pool; virStoragePoolDef pool = { 0 };
virStorageVolDef def; virStorageVolDef def = { 0 };
vboxIID hddIID; vboxIID hddIID;
PRUint32 hddstate; PRUint32 hddstate;
nsresult rc; nsresult rc;
@ -732,9 +731,6 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
memset(&pool, 0, sizeof(pool));
memset(&def, 0, sizeof(def));
if (virUUIDParse(vol->key, uuid) < 0) { if (virUUIDParse(vol->key, uuid) < 0) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("Could not parse UUID from '%1$s'"), vol->key); _("Could not parse UUID from '%1$s'"), vol->key);

View File

@ -1044,11 +1044,9 @@ virVMXVerifyDiskAddress(virDomainXMLOption *xmlopt,
virDomainDiskDef *disk, virDomainDiskDef *disk,
virDomainDef *vmdef) virDomainDef *vmdef)
{ {
virDomainDiskDef def; virDomainDiskDef def = { 0 };
virDomainDeviceDriveAddress *drive; virDomainDeviceDriveAddress *drive;
memset(&def, 0, sizeof(def));
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported disk address type '%1$s'"), _("Unsupported disk address type '%1$s'"),

View File

@ -39,14 +39,12 @@ testGetHostByName(const void *opaque)
{ {
const struct testNSSData *data = opaque; const struct testNSSData *data = opaque;
const bool existent = data->hostname && data->ipAddr && data->ipAddr[0]; const bool existent = data->hostname && data->ipAddr && data->ipAddr[0];
struct hostent resolved; struct hostent resolved = { 0 };
char buf[BUF_SIZE] = { 0 }; char buf[BUF_SIZE] = { 0 };
char **addrList; char **addrList;
int rv, tmp_errno = 0, tmp_herrno = 0; int rv, tmp_errno = 0, tmp_herrno = 0;
size_t i = 0; size_t i = 0;
memset(&resolved, 0, sizeof(resolved));
rv = NSS_NAME(gethostbyname2)(data->hostname, rv = NSS_NAME(gethostbyname2)(data->hostname,
data->af, data->af,
&resolved, &resolved,
@ -116,12 +114,10 @@ testGetHostByName(const void *opaque)
addrList = resolved.h_addr_list; addrList = resolved.h_addr_list;
i = 0; i = 0;
while (*addrList) { while (*addrList) {
virSocketAddr sa; virSocketAddr sa = { 0 };
g_autofree char *ipAddr = NULL; g_autofree char *ipAddr = NULL;
void *address = *addrList; void *address = *addrList;
memset(&sa, 0, sizeof(sa));
if (resolved.h_addrtype == AF_INET) { if (resolved.h_addrtype == AF_INET) {
virSocketAddrSetIPv4AddrNetOrder(&sa, *((uint32_t *) address)); virSocketAddrSetIPv4AddrNetOrder(&sa, *((uint32_t *) address));
} else { } else {

View File

@ -348,12 +348,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
g_autofree char *actualargv = NULL; g_autofree char *actualargv = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autoptr(GHashTable) vars = virHashNew(virNWFilterVarValueHashFree); g_autoptr(GHashTable) vars = virHashNew(virNWFilterVarValueHashFree);
virNWFilterInst inst; virNWFilterInst inst = { 0 };
int ret = -1; int ret = -1;
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew(); g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
memset(&inst, 0, sizeof(inst));
virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL); virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL);
if (testSetDefaultParameters(vars) < 0) if (testSetDefaultParameters(vars) < 0)

View File

@ -895,7 +895,7 @@ testQemuMonitorJSONGetObjectProperty(const void *opaque)
{ {
const testGenericData *data = opaque; const testGenericData *data = opaque;
virDomainXMLOption *xmlopt = data->xmlopt; virDomainXMLOption *xmlopt = data->xmlopt;
qemuMonitorJSONObjectProperty prop; qemuMonitorJSONObjectProperty prop = { 0 };
g_autoptr(qemuMonitorTest) test = NULL; g_autoptr(qemuMonitorTest) test = NULL;
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema))) if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
@ -906,7 +906,6 @@ testQemuMonitorJSONGetObjectProperty(const void *opaque)
return -1; return -1;
/* Present with path and property */ /* Present with path and property */
memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN; prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN;
if (qemuMonitorJSONGetObjectProperty(qemuMonitorTestGetMonitor(test), if (qemuMonitorJSONGetObjectProperty(qemuMonitorTestGetMonitor(test),
"/machine/i440fx", "/machine/i440fx",
@ -935,7 +934,7 @@ testQemuMonitorJSONSetObjectProperty(const void *opaque)
{ {
const testGenericData *data = opaque; const testGenericData *data = opaque;
virDomainXMLOption *xmlopt = data->xmlopt; virDomainXMLOption *xmlopt = data->xmlopt;
qemuMonitorJSONObjectProperty prop; qemuMonitorJSONObjectProperty prop = { 0 };
g_autoptr(qemuMonitorTest) test = NULL; g_autoptr(qemuMonitorTest) test = NULL;
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema))) if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
@ -949,7 +948,6 @@ testQemuMonitorJSONSetObjectProperty(const void *opaque)
return -1; return -1;
/* Let's attempt the setting */ /* Let's attempt the setting */
memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN; prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN;
prop.val.b = true; prop.val.b = true;
if (qemuMonitorJSONSetObjectProperty(qemuMonitorTestGetMonitor(test), if (qemuMonitorJSONSetObjectProperty(qemuMonitorTestGetMonitor(test),

View File

@ -874,9 +874,7 @@ qemuMonitorTestNew(virDomainXMLOption *xmlopt,
GHashTable *schema) GHashTable *schema)
{ {
g_autoptr(qemuMonitorTest) test = NULL; g_autoptr(qemuMonitorTest) test = NULL;
virDomainChrSourceDef src; virDomainChrSourceDef src = { 0 };
memset(&src, 0, sizeof(src));
if (!(test = qemuMonitorCommonTestNew(xmlopt, vm, &src))) if (!(test = qemuMonitorCommonTestNew(xmlopt, vm, &src)))
goto error; goto error;
@ -1185,9 +1183,7 @@ qemuMonitorTest *
qemuMonitorTestNewAgent(virDomainXMLOption *xmlopt) qemuMonitorTestNewAgent(virDomainXMLOption *xmlopt)
{ {
g_autoptr(qemuMonitorTest) test = NULL; g_autoptr(qemuMonitorTest) test = NULL;
virDomainChrSourceDef src; virDomainChrSourceDef src = { 0 };
memset(&src, 0, sizeof(src));
if (!(test = qemuMonitorCommonTestNew(xmlopt, NULL, &src))) if (!(test = qemuMonitorCommonTestNew(xmlopt, NULL, &src)))
goto error; goto error;

View File

@ -546,7 +546,7 @@ testCompareXMLToArgv(const void *data)
unsigned int parseFlags = info->parseFlags; unsigned int parseFlags = info->parseFlags;
int ret = -1; int ret = -1;
virDomainObj *vm = NULL; virDomainObj *vm = NULL;
virDomainChrSourceDef monitor_chr; virDomainChrSourceDef monitor_chr = { 0 };
g_autoptr(virConnect) conn = NULL; g_autoptr(virConnect) conn = NULL;
virError *err = NULL; virError *err = NULL;
g_autofree char *log = NULL; g_autofree char *log = NULL;
@ -558,8 +558,6 @@ testCompareXMLToArgv(const void *data)
virArch arch = VIR_ARCH_NONE; virArch arch = VIR_ARCH_NONE;
g_autoptr(virIdentity) sysident = virIdentityGetSystem(); g_autoptr(virIdentity) sysident = virIdentityGetSystem();
memset(&monitor_chr, 0, sizeof(monitor_chr));
if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0) if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0)
goto cleanup; goto cleanup;

View File

@ -30,7 +30,7 @@ linuxTestCompareFiles(const char *cpuinfofile,
const char *outputfile) const char *outputfile)
{ {
g_autofree char *actualData = NULL; g_autofree char *actualData = NULL;
virNodeInfo nodeinfo; virNodeInfo nodeinfo = { 0 };
g_autoptr(FILE) cpuinfo = NULL; g_autoptr(FILE) cpuinfo = NULL;
cpuinfo = fopen(cpuinfofile, "r"); cpuinfo = fopen(cpuinfofile, "r");
@ -40,7 +40,6 @@ linuxTestCompareFiles(const char *cpuinfofile,
return -1; return -1;
} }
memset(&nodeinfo, 0, sizeof(nodeinfo));
if (virHostCPUGetInfoPopulateLinux(cpuinfo, arch, if (virHostCPUGetInfoPopulateLinux(cpuinfo, arch,
&nodeinfo.cpus, &nodeinfo.mhz, &nodeinfo.cpus, &nodeinfo.mhz,
&nodeinfo.nodes, &nodeinfo.sockets, &nodeinfo.nodes, &nodeinfo.sockets,

View File

@ -179,7 +179,7 @@ static int testMessageHeaderDecode(const void *args G_GNUC_UNUSED)
static int testMessagePayloadEncode(const void *args G_GNUC_UNUSED) static int testMessagePayloadEncode(const void *args G_GNUC_UNUSED)
{ {
virNetMessageError err; virNetMessageError err = { 0 };
virNetMessage *msg = virNetMessageNew(true); virNetMessage *msg = virNetMessageNew(true);
int ret = -1; int ret = -1;
static const char expect[] = { static const char expect[] = {
@ -218,8 +218,6 @@ static int testMessagePayloadEncode(const void *args G_GNUC_UNUSED)
if (!msg) if (!msg)
return -1; return -1;
memset(&err, 0, sizeof(err));
err.code = VIR_ERR_INTERNAL_ERROR; err.code = VIR_ERR_INTERNAL_ERROR;
err.domain = VIR_FROM_RPC; err.domain = VIR_FROM_RPC;
err.level = VIR_ERR_ERROR; err.level = VIR_ERR_ERROR;
@ -287,7 +285,7 @@ static int testMessagePayloadEncode(const void *args G_GNUC_UNUSED)
static int testMessagePayloadDecode(const void *args G_GNUC_UNUSED) static int testMessagePayloadDecode(const void *args G_GNUC_UNUSED)
{ {
virNetMessageError err; virNetMessageError err = { 0 };
virNetMessage *msg = virNetMessageNew(true); virNetMessage *msg = virNetMessageNew(true);
static char input_buffer[] = { static char input_buffer[] = {
0x00, 0x00, 0x00, 0x74, /* Length */ 0x00, 0x00, 0x00, 0x74, /* Length */
@ -323,8 +321,6 @@ static int testMessagePayloadDecode(const void *args G_GNUC_UNUSED)
}; };
int ret = -1; int ret = -1;
memset(&err, 0, sizeof(err));
if (!msg) if (!msg)
return -1; return -1;

View File

@ -484,13 +484,12 @@ aiforaf(const char *name, int af, struct addrinfo *pai, struct addrinfo **aip)
struct sockaddr sa; struct sockaddr sa;
struct sockaddr_in sin; struct sockaddr_in sin;
struct sockaddr_in6 sin6; struct sockaddr_in6 sin6;
} sa; } sa = { 0 };
socklen_t salen; socklen_t salen;
void *address = *addrList; void *address = *addrList;
char host[NI_MAXHOST]; char host[NI_MAXHOST];
char port[NI_MAXSERV]; char port[NI_MAXSERV];
memset(&sa, 0, sizeof(sa));
if (resolved.h_addrtype == AF_INET) { if (resolved.h_addrtype == AF_INET) {
sa.sin.sin_family = AF_INET; sa.sin.sin_family = AF_INET;
memcpy(&sa.sin.sin_addr.s_addr, memcpy(&sa.sin.sin_addr.s_addr,

View File

@ -1210,7 +1210,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
{ {
virDomainInfo info; virDomainInfo info;
g_autoptr(virshDomain) dom = NULL; g_autoptr(virshDomain) dom = NULL;
virSecurityModel secmodel; virSecurityModel secmodel = { 0 };
int persistent = 0; int persistent = 0;
bool ret = true; bool ret = true;
int autostart; int autostart;
@ -1288,7 +1288,6 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
has_managed_save ? _("yes") : _("no")); has_managed_save ? _("yes") : _("no"));
/* Security model and label information */ /* Security model and label information */
memset(&secmodel, 0, sizeof(secmodel));
if (virNodeGetSecurityModel(priv->conn, &secmodel) == -1) { if (virNodeGetSecurityModel(priv->conn, &secmodel) == -1) {
if (last_error->code != VIR_ERR_NO_SUPPORT) { if (last_error->code != VIR_ERR_NO_SUPPORT) {
return false; return false;

View File

@ -6182,7 +6182,7 @@ virshDomainJobStatsToDomainJobInfo(virTypedParameterPtr params,
static bool static bool
cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
{ {
virDomainJobInfo info; virDomainJobInfo info = { 0 };
g_autoptr(virshDomain) dom = NULL; g_autoptr(virshDomain) dom = NULL;
bool ret = false; bool ret = false;
const char *unit; const char *unit;
@ -6209,8 +6209,6 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "keep-completed")) if (vshCommandOptBool(cmd, "keep-completed"))
flags |= VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED; flags |= VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED;
memset(&info, 0, sizeof(info));
rc = virDomainGetJobStats(dom, &info.type, &params, &nparams, flags); rc = virDomainGetJobStats(dom, &info.type, &params, &nparams, flags);
if (rc == 0) { if (rc == 0) {
if (virshDomainJobStatsToDomainJobInfo(params, nparams, &info) < 0) if (virshDomainJobStatsToDomainJobInfo(params, nparams, &info) < 0)

View File

@ -204,9 +204,7 @@ vshTableSafeEncode(const char *s, size_t *width)
size_t sz = s ? strlen(s) : 0; size_t sz = s ? strlen(s) : 0;
char *buf; char *buf;
char *ret; char *ret;
mbstate_t st; mbstate_t st = { 0 };
memset(&st, 0, sizeof(st));
buf = g_new0(char, (sz * HEX_ENCODE_LENGTH) + 1); buf = g_new0(char, (sz * HEX_ENCODE_LENGTH) + 1);