[Libvirt-cim] [PATCH] [RFC] [CU] Turn std_indication's awesome knob to eleven

Dan Smith danms at us.ibm.com
Fri Feb 8 15:07:14 UTC 2008


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 at us.ibm.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20080208/c0e37a8e/attachment.sig>


More information about the Libvirt-cim mailing list