JG> +char *classname_from_inst(const CMPIBroker *broker,
JG> + CMPIInstance *inst,
JG> + CMPIStatus *s)
JG> +{
JG> + char *ret = NULL;
JG> +
JG> + CMPIObjectPath *ref;
JG> + ref = CMGetObjectPath(inst, s);
JG> + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) {
JG> + cu_statusf(broker, s,
JG> + CMPI_RC_ERR_FAILED,
JG> + "Could not get objectpath from instance");
JG> + goto out;
JG> + }
JG> +
JG> + ret = strdup(CLASSNAME(ref));
JG> +
JG> + out:
JG> + return ret;
JG> }
This could probably be a distinct patch as well.
Also, why strdup the result of CLASSNAME()? It's CIMOM-managed
memory, and most of the other libcu functions have been modified to
avoid dynamic memory where possible. The return value should be const
char * after this change.
Also, why not just signal your single error case by returning NULL?
That way you can avoid having to pass in the broker and the status
pointers and the function becomes a bit cleaner.
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com