Declare it at the beginning of the function instead of right before use. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/security/security_dac.c | 20 ++++++++++---------- src/security/security_selinux.c | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index dd701ef28b..d9d4cda159 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1945,6 +1945,11 @@ virSecurityDACRestoreAllLabel(virSecurityManagerPtr mgr, size_t i; int rc = 0; + struct _virSecuritySELinuxChardevCallbackData chardevData = { + .mgr = mgr, + .chardevStdioLogd = chardevStdioLogd, + }; + secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME); if (!priv->dynamicOwnership || (secdef && !secdef->relabel)) @@ -1986,11 +1991,6 @@ virSecurityDACRestoreAllLabel(virSecurityManagerPtr mgr, rc = -1; } - struct _virSecuritySELinuxChardevCallbackData chardevData = { - .mgr = mgr, - .chardevStdioLogd = chardevStdioLogd, - }; - if (virDomainChrDefForeach(def, false, virSecurityDACRestoreChardevCallback, @@ -2152,6 +2152,11 @@ virSecurityDACSetAllLabel(virSecurityManagerPtr mgr, uid_t user; gid_t group; + struct _virSecuritySELinuxChardevCallbackData chardevData = { + .mgr = mgr, + .chardevStdioLogd = chardevStdioLogd, + }; + secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME); if (!priv->dynamicOwnership || (secdef && !secdef->relabel)) @@ -2192,11 +2197,6 @@ virSecurityDACSetAllLabel(virSecurityManagerPtr mgr, return -1; } - struct _virSecuritySELinuxChardevCallbackData chardevData = { - .mgr = mgr, - .chardevStdioLogd = chardevStdioLogd, - }; - if (virDomainChrDefForeach(def, true, virSecurityDACSetChardevCallback, diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index cc8fb1099c..87741d6dad 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2767,6 +2767,11 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManagerPtr mgr, size_t i; int rc = 0; + struct _virSecuritySELinuxChardevCallbackData chardevData = { + .mgr = mgr, + .chardevStdioLogd = chardevStdioLogd + }; + VIR_DEBUG("Restoring security label on %s migrated=%d", def->name, migrated); secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME); @@ -2805,11 +2810,6 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManagerPtr mgr, rc = -1; } - struct _virSecuritySELinuxChardevCallbackData chardevData = { - .mgr = mgr, - .chardevStdioLogd = chardevStdioLogd - }; - if (virDomainChrDefForeach(def, false, virSecuritySELinuxRestoreSecurityChardevCallback, @@ -3165,6 +3165,11 @@ virSecuritySELinuxSetAllLabel(virSecurityManagerPtr mgr, virSecuritySELinuxDataPtr data = virSecurityManagerGetPrivateData(mgr); virSecurityLabelDefPtr secdef; + struct _virSecuritySELinuxChardevCallbackData chardevData = { + .mgr = mgr, + .chardevStdioLogd = chardevStdioLogd + }; + secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME); if (!secdef || !secdef->relabel || data->skipAllLabel) @@ -3208,11 +3213,6 @@ virSecuritySELinuxSetAllLabel(virSecurityManagerPtr mgr, return -1; } - struct _virSecuritySELinuxChardevCallbackData chardevData = { - .mgr = mgr, - .chardevStdioLogd = chardevStdioLogd - }; - if (virDomainChrDefForeach(def, true, virSecuritySELinuxSetSecurityChardevCallback, -- 2.26.2