We currently have 2 methods that do the capability matching. This should
be condensed to a single function and all the derivates should just call
into that using a proper type conversion.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
src/conf/virnodedeviceobj.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index c4e3a40d3..a4d38b3a1 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -53,6 +53,8 @@ static virClassPtr virNodeDeviceObjClass;
static virClassPtr virNodeDeviceObjListClass;
static void virNodeDeviceObjDispose(void *opaque);
static void virNodeDeviceObjListDispose(void *opaque);
+static bool virNodeDeviceObjHasCapStr(const virNodeDeviceObj *obj,
+ const char *cap);
static int
virNodeDeviceObjOnceInit(void)
@@ -121,8 +123,8 @@ virNodeDeviceObjGetDef(virNodeDeviceObjPtr obj)
static bool
-virNodeDeviceObjHasCap(const virNodeDeviceObj *obj,
- const char *cap)
+virNodeDeviceObjHasCapStr(const virNodeDeviceObj *obj,
+ const char *cap)
{
virNodeDevCapsDefPtr caps = obj->def->caps;
const char *fc_host_cap =
@@ -375,7 +377,7 @@ virNodeDeviceObjListFindByCapCallback(const void *payload,
int want = 0;
virObjectLock(obj);
- if (virNodeDeviceObjHasCap(obj, matchstr))
+ if (virNodeDeviceObjHasCapStr(obj, matchstr))
want = 1;
virObjectUnlock(obj);
return want;
@@ -750,7 +752,7 @@ virNodeDeviceObjListNumOfDevicesCallback(void *payload,
virObjectLock(obj);
def = obj->def;
if ((!filter || filter(data->conn, def)) &&
- (!data->matchstr || virNodeDeviceObjHasCap(obj, data->matchstr)))
+ (!data->matchstr || virNodeDeviceObjHasCapStr(obj, data->matchstr)))
data->count++;
virObjectUnlock(obj);
@@ -805,7 +807,7 @@ virNodeDeviceObjListGetNamesCallback(void *payload,
def = obj->def;
if ((!filter || filter(data->conn, def)) &&
- (!data->matchstr || virNodeDeviceObjHasCap(obj, data->matchstr))) {
+ (!data->matchstr || virNodeDeviceObjHasCapStr(obj, data->matchstr))) {
if (VIR_STRDUP(data->names[data->nnames], def->name) < 0) {
data->error = true;
goto cleanup;
--
2.13.6