debuggers.hg
changeset 22865:67d5b8004947
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>
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>
author | Ian Jackson <ian.jackson@eu.citrix.com> |
---|---|
date | Wed Jan 26 11:58:45 2011 +0000 (2011-01-26) |
parents | 00e1fd80e1f7 |
children | 310cc33bfc81 |
files | tools/libxl/libxl.h tools/libxl/libxl_utils.c |
line diff
1.1 --- a/tools/libxl/libxl.h Wed Jan 26 11:47:52 2011 +0000 1.2 +++ b/tools/libxl/libxl.h Wed Jan 26 11:58:45 2011 +0000 1.3 @@ -232,12 +232,13 @@ typedef struct { 1.4 } libxl_domain_suspend_info; 1.5 1.6 enum { 1.7 - ERROR_VERSION = -1, 1.8 - ERROR_FAIL = -2, 1.9 - ERROR_NI = -3, 1.10 - ERROR_NOMEM = -4, 1.11 - ERROR_INVAL = -5, 1.12 - ERROR_BADFAIL = -6, 1.13 + ERROR_NONSPECIFIC = -1, 1.14 + ERROR_VERSION = -2, 1.15 + ERROR_FAIL = -3, 1.16 + ERROR_NI = -4, 1.17 + ERROR_NOMEM = -5, 1.18 + ERROR_INVAL = -6, 1.19 + ERROR_BADFAIL = -7, 1.20 }; 1.21 1.22 #define LIBXL_VERSION 0
2.1 --- a/tools/libxl/libxl_utils.c Wed Jan 26 11:47:52 2011 +0000 2.2 +++ b/tools/libxl/libxl_utils.c Wed Jan 26 11:58:45 2011 +0000 2.3 @@ -93,7 +93,7 @@ int libxl_name_to_domid(libxl_ctx *ctx, 2.4 int i, nb_domains; 2.5 char *domname; 2.6 libxl_dominfo *dominfo; 2.7 - int ret = -1; 2.8 + int ret = ERROR_INVAL; 2.9 2.10 dominfo = libxl_list_domain(ctx, &nb_domains); 2.11 if (!dominfo) 2.12 @@ -142,7 +142,7 @@ int libxl_name_to_cpupoolid(libxl_ctx *c 2.13 int i, nb_pools; 2.14 char *poolname; 2.15 libxl_cpupoolinfo *poolinfo; 2.16 - int ret = -1; 2.17 + int ret = ERROR_INVAL; 2.18 2.19 poolinfo = libxl_list_cpupool(ctx, &nb_pools); 2.20 if (!poolinfo) 2.21 @@ -171,7 +171,7 @@ int libxl_name_to_schedid(libxl_ctx *ctx 2.22 if (strcmp(name, schedid_name[i].name) == 0) 2.23 return schedid_name[i].id; 2.24 2.25 - return -1; 2.26 + return ERROR_INVAL; 2.27 } 2.28 2.29 char *libxl_schedid_to_name(libxl_ctx *ctx, int schedid) 2.30 @@ -287,7 +287,7 @@ int libxl_string_to_phystype(libxl_ctx * 2.31 } else if (!strcmp(s, "tap")) { 2.32 p = strchr(s, ':'); 2.33 if (!p) { 2.34 - rc = -1; 2.35 + rc = ERROR_INVAL; 2.36 goto out; 2.37 } 2.38 p++;