From 004d5141c59b08904396d53efe64ebe15f30c7b6 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 17 Apr 2023 10:10:04 +0200 Subject: [PATCH] conf: Initialize _virNetworkObj::dnsmasqPid to -1 in virNetworkObjNew() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Throughout all of our network driver code we assume that dnsmasqPid of value -1 means the network has no dnsmasq process running. There are plenty of calls to: virNetworkObjSetDnsmasqPid(obj, -1); or: pid_t dnsmasqPid = virNetworkObjGetDnsmasqPid(obj); if (dnsmasqPid > 0) ...; Now, a virNetworkObj is created via virNetworkObjNew() which might as well set this de-facto default value. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/conf/virnetworkobj.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 1726fc381f..b8b86da06f 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -117,6 +117,7 @@ virNetworkObjNew(void) ignore_value(virBitmapSetBit(obj->classIdMap, 2)); obj->ports = virHashNew(virNetworkObjPortFree); + obj->dnsmasqPid = (pid_t)-1; virObjectLock(obj);