diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2011-01-26 11:58:45 +0000 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2011-01-26 11:58:45 +0000 |
commit | a6998c944c4bbfc13804f20958953cdcd686f762 (patch) | |
tree | 30423e69d850435284976f1e1699aa5f37b271dd | |
parent | c80ed144feb3bcf697e13204207e6863f0e2b9b0 (diff) | |
download | xen-a6998c944c4bbfc13804f20958953cdcd686f762.tar.gz xen-a6998c944c4bbfc13804f20958953cdcd686f762.tar.bz2 xen-a6998c944c4bbfc13804f20958953cdcd686f762.zip |
libxl: band-aid for functions which return literal "-1"
Many libxl functions erroneously return "-1" on error, rather than
some ERROR_* value.
To deal with this, invent a new ERROR_NONSPECIFIC "-1" which indicates
that "the function which generated this error code is broken".
Fix up the one we care about for forthcoming duplicate domain
detection (libxl_name_to_domid) and the others following the same
pattern nearby; leave the rest for post-4.1.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
-rw-r--r-- | tools/libxl/libxl.h | 13 | ||||
-rw-r--r-- | tools/libxl/libxl_utils.c | 8 |
2 files changed, 11 insertions, 10 deletions
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 1160de3c8c..d608e99ca4 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -232,12 +232,13 @@ typedef struct { } libxl_domain_suspend_info; enum { - ERROR_VERSION = -1, - ERROR_FAIL = -2, - ERROR_NI = -3, - ERROR_NOMEM = -4, - ERROR_INVAL = -5, - ERROR_BADFAIL = -6, + ERROR_NONSPECIFIC = -1, + ERROR_VERSION = -2, + ERROR_FAIL = -3, + ERROR_NI = -4, + ERROR_NOMEM = -5, + ERROR_INVAL = -6, + ERROR_BADFAIL = -7, }; #define LIBXL_VERSION 0 diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 64c884fd77..a44f8af3e4 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -93,7 +93,7 @@ int libxl_name_to_domid(libxl_ctx *ctx, const char *name, int i, nb_domains; char *domname; libxl_dominfo *dominfo; - int ret = -1; + int ret = ERROR_INVAL; dominfo = libxl_list_domain(ctx, &nb_domains); if (!dominfo) @@ -142,7 +142,7 @@ int libxl_name_to_cpupoolid(libxl_ctx *ctx, const char *name, int i, nb_pools; char *poolname; libxl_cpupoolinfo *poolinfo; - int ret = -1; + int ret = ERROR_INVAL; poolinfo = libxl_list_cpupool(ctx, &nb_pools); if (!poolinfo) @@ -171,7 +171,7 @@ int libxl_name_to_schedid(libxl_ctx *ctx, const char *name) if (strcmp(name, schedid_name[i].name) == 0) return schedid_name[i].id; - return -1; + return ERROR_INVAL; } char *libxl_schedid_to_name(libxl_ctx *ctx, int schedid) @@ -287,7 +287,7 @@ int libxl_string_to_phystype(libxl_ctx *ctx, char *s, libxl_disk_phystype *physt } else if (!strcmp(s, "tap")) { p = strchr(s, ':'); if (!p) { - rc = -1; + rc = ERROR_INVAL; goto out; } p++; |