Message ID | 20160408022407.9058.8250.stgit@Solace.fritz.box (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Apr 08, 2016 at 04:24:07AM +0200, Dario Faggioli wrote: > create_domain() is of uint32_t return type, because on > success it returns the domid of the new domain, and > uint32_t is what we typically use for domid-s. > > However, on failure, it returns ERROR_FAIL or ERROR_INVAL, > which are -3 and -6. Callers assign the return value to an > 'int rc' variable and then check for '(rc < 0)'. > > Although things work, and no tool (compiler, Coverity, ecc.) > is complaining, using 'int' as return type seems better. > > Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com> > --- > Cc: Ian Jackson <ian.jackson@eu.citrix.com> > Cc: Wei Liu <wei.liu2@citrix.com> > Cc: Andrew Cooper <andrew.cooper3@citrix.com> > --- > tools/libxl/xl_cmdimpl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 823cb46..d2ad8c8 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -2777,7 +2777,7 @@ static void evdisable_disk_ejects(libxl_evgen_disk_eject **diskws, > } > } > > -static uint32_t create_domain(struct domain_create *dom_info) > +static int create_domain(struct domain_create *dom_info) > { > uint32_t domid = INVALID_DOMID; > >
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 823cb46..d2ad8c8 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2777,7 +2777,7 @@ static void evdisable_disk_ejects(libxl_evgen_disk_eject **diskws, } } -static uint32_t create_domain(struct domain_create *dom_info) +static int create_domain(struct domain_create *dom_info) { uint32_t domid = INVALID_DOMID;
create_domain() is of uint32_t return type, because on success it returns the domid of the new domain, and uint32_t is what we typically use for domid-s. However, on failure, it returns ERROR_FAIL or ERROR_INVAL, which are -3 and -6. Callers assign the return value to an 'int rc' variable and then check for '(rc < 0)'. Although things work, and no tool (compiler, Coverity, ecc.) is complaining, using 'int' as return type seems better. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> --- Cc: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Wei Liu <wei.liu2@citrix.com> Cc: Andrew Cooper <andrew.cooper3@citrix.com> --- tools/libxl/xl_cmdimpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)