# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1194548973 28800
# Node ID a55a0f630c034ac5ed76211b8459ae1e4fdc56ae
# Parent 41c761dba6a6268da6fdb9a89c1cc6f959870aac
Make cu_compare_ref() also compare the actual classname of the ref and inst
...and change STREQ to STREQC, per Heidi's suggestion.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 41c761dba6a6 -r a55a0f630c03 instance_util.c
--- a/instance_util.c Thu Nov 08 10:28:41 2007 -0800
+++ b/instance_util.c Thu Nov 08 11:09:33 2007 -0800
@@ -78,7 +78,7 @@ static bool _compare_data(const CMPIData
const char *as = CMGetCharPtr(a->value.string);
const char *bs = CMGetCharPtr(b->value.string);
- return STREQ(as, bs);
+ return STREQC(as, bs);
} else if (a->type & CMPI_INTEGER) {
return memcmp(&a->value, &b->value, sizeof(a->value)) ==
0;
}
@@ -86,6 +86,29 @@ static bool _compare_data(const CMPIData
CU_DEBUG("Unhandled CMPI type: `%i'", a->type);
return false;
+}
+
+static bool _compare_classname(const CMPIObjectPath *ref,
+ const CMPIInstance *inst)
+{
+ const char *ref_cn;
+ const char *inst_cn;
+ CMPIObjectPath *op;
+ CMPIStatus s;
+
+ op = CMGetObjectPath(inst, &s);
+ if ((op == NULL) || (s.rc != CMPI_RC_OK))
+ return false;
+
+ ref_cn = CLASSNAME(ref);
+ if (ref_cn == NULL)
+ return false;
+
+ inst_cn = CLASSNAME(op);
+ if (inst_cn == NULL)
+ return false;
+
+ return STREQC(inst_cn, ref_cn);
}
const char *cu_compare_ref(const CMPIObjectPath *ref,
@@ -101,6 +124,9 @@ const char *cu_compare_ref(const CMPIObj
CU_DEBUG("Unable to get key count");
return NULL;
}
+
+ if (!_compare_classname(ref, inst))
+ return "CreationClassName";
for (i = 0; i < count; i++) {
CMPIData kd, pd;