Usually, we want a function to be as reusable as possible. But in this specific case, when it's used just once we don't need that. The lxcCreateHostdevDef() function is meant to create a hostdev. The first argument selects the hostdev mode (caps/subsys) and the second argument selects the type of hostdev (NET/STORAGE/MISC). But because of how the function is written, it's impossible to create a subsys hostdev as the function sets hostdev->source.caps.type, regardless of mode. So the @mode argument can be dropped. Then, the function is called from one place and one place only. And in there, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET is passed for @type so we can drop that argument too. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/lxc/lxc_native.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index d311f5a5ad..0ae208ef11 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -375,18 +375,16 @@ lxcCreateNetDef(const char *type, } static virDomainHostdevDef * -lxcCreateHostdevDef(int mode, int type, const char *data) +lxcCreateHostdevDef(const char *data) { virDomainHostdevDef *hostdev = virDomainHostdevDefNew(); if (!hostdev) return NULL; - hostdev->mode = mode; - hostdev->source.caps.type = type; - - if (type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) - hostdev->source.caps.u.net.ifname = g_strdup(data); + hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES; + hostdev->source.caps.type = VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET; + hostdev->source.caps.u.net.ifname = g_strdup(data); return hostdev; } @@ -457,9 +455,7 @@ lxcAddNetworkDefinition(virDomainDef *def, lxcNetworkParseData *data) _("Missing 'link' attribute for NIC")); goto error; } - if (!(hostdev = lxcCreateHostdevDef(VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES, - VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET, - data->link))) + if (!(hostdev = lxcCreateHostdevDef(data->link))) goto error; /* This still requires the user to manually setup the vlan interface -- 2.39.2