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

Re: [Xen-devel] [PATCH 2/5] libxl: add xlu_cfg_get_type function



Andre Przywara writes ("[Xen-devel] [PATCH 2/5] libxl: add xlu_cfg_get_type 
function"):
> As cpuid= can be used with two syntaxes (one as a list, the other as a
> string), we need to distinguish them without an error message. Introduce
> a helper function to detect the type of entry used before issuing a warning.

Thanks.  This is a generally good idea although I'm not quite
convinced by this:

 +    errno = 0;
 +    l = strtol(set->values[0], &endptr, 0);
 +    if (errno == EINVAL || endptr == set->values[0])
 +        return XLU_CFG_STRING;
 +    return XLU_CFG_LONG;

Firstly, it will fail for unsigned longs bigger than LONG_MAX, and we
would normally think about unsigned longs.  Secondly, if callers say
things like
  if (type == XLU_CFG_STRING) ....
they'll have a bug.

I would suggest XLU_CFG_ATOM.  Callers can use strto[u]l (or whatever)
themselves if they need to distinguish numbers from strings.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.