The virNetworkObjSetMacMap() API effectively steals passed @macmap argument. However, the argument is a plain, first order pointer. This requires every caller to set the argument to NULL after the function was called. Let's make the function take double pointer instead to make it obvious that the argument is consumed. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/virnetworkobj.c | 4 ++-- src/conf/virnetworkobj.h | 2 +- src/network/bridge_driver.c | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 46b499db58..cc3b93db6d 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -240,9 +240,9 @@ virNetworkObjSetFloorSum(virNetworkObj *obj, void virNetworkObjSetMacMap(virNetworkObj *obj, - virMacMap *macmap) + virMacMap **macmap) { - obj->macmap = macmap; + obj->macmap = g_steal_pointer(macmap); } diff --git a/src/conf/virnetworkobj.h b/src/conf/virnetworkobj.h index fadd277cbd..7d34fa3204 100644 --- a/src/conf/virnetworkobj.h +++ b/src/conf/virnetworkobj.h @@ -78,7 +78,7 @@ virNetworkObjSetFloorSum(virNetworkObj *obj, void virNetworkObjSetMacMap(virNetworkObj *obj, - virMacMap *macmap); + virMacMap **macmap); void virNetworkObjUnrefMacMap(virNetworkObj *obj); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index a07af55390..024487b359 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -475,8 +475,7 @@ networkUpdateState(virNetworkObj *obj, if (!(macmap = virMacMapNew(macMapFile))) return -1; - virNetworkObjSetMacMap(obj, macmap); - macmap = NULL; + virNetworkObjSetMacMap(obj, &macmap); break; @@ -1972,8 +1971,7 @@ networkStartNetworkVirtual(virNetworkDriverState *driver, !(macmap = virMacMapNew(macMapFile))) goto error; - virNetworkObjSetMacMap(obj, macmap); - macmap = NULL; + virNetworkObjSetMacMap(obj, &macmap); /* Set bridge options */ -- 2.35.1