[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 4/8] Define internal APIs for managing identities



On 03/06/2013 05:49 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> 
> Introduce a local object virIdentity for managing security
> attributes used to form a client application's identity.
> Instances of this object are intended to be used as if they
> were immutable, once created & populated with attributes
> 
> Signed-off-by: Daniel P. Berrange <berrange redhat com>
> ---

> +/**
> + * virIdentitySetAttr:
> + * @ident: the identity to modify
> + * @attr: the attribute type to set
> + * @value: the identifying value to associate with @attr
> + *
> + * Sets an identifying attribute @attr on @ident. Each
> + * @attr type can only be set once.
> + *
> + * Returns: 0 on success, or -1 on error
> + */
> +int virIdentitySetAttr(virIdentityPtr ident,
> +                       unsigned int attr,
> +                       const char *value)
> +{
> +    int ret = -1;
> +    VIR_DEBUG("ident=%p attribute=%u value=%s", ident, attr, NULLSTR(value));

This says value can be NULL...

> +
> +    if (ident->attrs[attr]) {
> +        virReportError(VIR_ERR_OPERATION_DENIED, "%s",
> +                        _("Identity attribute is already set"));
> +        goto cleanup;
> +    }
> +
> +    if (!(ident->attrs[attr] = strdup(value))) {

...but this would crash.  Isn't it easier to just require that value be
non-NULL if you are going to call this function?

> +
> +    if (!virIdentityIsEqual(identa, identb)) {
> +        VIR_DEBUG("Empty identities were no equal");

s/no/not/


> +
> +    if (virIdentityIsEqual(identa, identb)) {
> +        VIR_DEBUG("Mis-atched identities should not be equal");

s/Mis-atched/Mismatched/

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]