Kaitlin Rupert wrote:
Heidi Eckhart wrote:
I like the idea of a validate function. But the body of GetInstance()
is almost identical to the body of validate_domain_ref() - the only
exception is that one returns an instance and the other returns a status.
Could these functions be consolidated?
You could change get_domain() to something like _get_domain(). Then
get_domain() could call _get_domain() and validate_domain_ref(). When
you need the instance returned, you can use get_domain(), otherwise
you can just call validate_domain_ref() directly to validate.
In general a very good idea, but it causes a "hen and egg" situation.
The intention of validate_domain_ref() is to be used by other providers
to check if the client given object path is valid for this system. That
means validate_domain_ref() can only get the object path as input
parameter (besides the broker), because it should not be the calling
function's responsibility to retrieve the domain instance before using
validate_domain_ref(). This means validate_domain_ref() has to retrieve
the real instance and compare this one against the client given object path.
If the functions are reordered like above, this causes that get_domain()
calls _get_domain() twice. First to retrieve the instance for a later
returning - and second within validate_domain_ref() as it needs the
instance for the comparison. So validate_domain_ref() can not be used
internally. Its only an interface for external provider usage.
But your comments made me rethink about the patch. So I've consolidated
and reordered a bit.
- added a new function to libcmpiutil - cu_validate_ref(ref, inst) -
that does the check between the system instance and the client given
instance
- get_domain() is now using the new libcmpiutil function
- the parameter CMPIInstance **inst is now used to "configure"
get_domain(); for internal usage the inst is returned and for external
usage this can be ignored by setting it to NULL
- validate_domain_ref() is now only an interface name for the client;
this could also be removed and the provider has then to call
get_domain(broker, ref, NULL) or simply ignores the returned instance;
but what I do not really like is, that this can confuse the reader of
the code; but I'm open for discussion and opinions
Will send out the patch soon.
--
Regards
Heidi Eckhart
Software Engineer
IBM Linux Technology Center - Open Hypervisor