[Libvirt-cim] [PATCH] [RFC] [CU] Turn std_indication's awesome knob to eleven
Jay Gagnon
grendel at linux.vnet.ibm.com
Fri Feb 8 15:41:11 UTC 2008
Dan Smith wrote:
> 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.
>
As this illustrates, I'm never really sure whether or not strdup is the
right thing to do. It would appear that it's unnecessary here, so I'll
take it out.
> 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.
>
Probably just my natural tendency to over-complicate. I'll fix that as
well.
--
-Jay
More information about the Libvirt-cim
mailing list