[Libvirt-cim] [PATCH] Fix VSMS instance code to refuse to return an instance if ref is invalid

Dan Smith danms at us.ibm.com
Mon Oct 29 20:30:26 UTC 2007


DS> +static int compare_prop(const CMPIObjectPath *ref,
DS> +                        const CMPIInstance *inst,
DS> +                        const char *name,
DS> +                        int mandatory)
DS> +{
DS> +        char *prop = NULL;
DS> +        char *key = NULL;
DS> +        int rc = 0;
DS> +
DS> +        key = cu_get_str_path(ref, name);
DS> +        if (key == NULL) {
DS> +                rc = !mandatory;
DS> +                goto out;
DS> +        }
DS> +
DS> +        if (cu_get_str_prop(inst, name, &prop) != CMPI_RC_OK)
DS> +                goto out;
DS> +
DS> +        rc = STREQ(key, prop);
DS> + out:
DS> +        free(prop);
DS> +        free(key);
DS> +
DS> +        return rc;
DS> +}

I think that some variation of the above function probably deserves to
be in libcmpiutil.  The act of comparing an instance with a reference
and make sure that all keys are either correct or unspecified seems
like a common thing.  There are probably other places where we need
such a filter anyway.  Thoughts?

-- 
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/20071029/70a97d5d/attachment.sig>


More information about the Libvirt-cim mailing list