xl: initialise rc before using it in vcpuset
PATCH v2 1/1 xl: initialise rc before using it in vcpuset
In 5b725e56 (xl: improve return and exit codes of vcpu related functions), the return value of libxl_cpu_bitmap_alloc was not stored in rc anymore. Yet the subsequent fprintf still used that.
Reinstate the original implementation, that is, to store return value of libxl_cpu_bitmap_alloc in rc before using rc.
---
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Dario Faggioli <[email protected]>
Cc: Harmandeep Kaur <[email protected]>
Cc: Andrew Cooper <[email protected]>
v2: print rc.
--- tools/libxl/xl_cmdimpl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +2 -1
@@ -5473,7 +5473,8 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)if (rc)return 1 ; } -if (libxl_cpu_bitmap_alloc (ctx, &cpumap, max_vcpus)) { + rc =libxl_cpu_bitmap_alloc (ctx, &cpumap, max_vcpus); +if (rc) {fprintf (stderr,"libxl_cpu_bitmap_alloc failed, rc: %d\n" , rc);return 1 ; }
Signature · 1 line
2.1.4
Quoted 14 lines · Wei Liu
tools/libxl/xl_cmdimpl.c +2
-1@@ -5473,7 +5473,8 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)if (rc)return 1 ; } -if (libxl_cpu_bitmap_alloc (ctx, &cpumap, max_vcpus)) { + rc =libxl_cpu_bitmap_alloc (ctx, &cpumap, max_vcpus); +if (rc) {fprintf (stderr,"libxl_cpu_bitmap_alloc failed, rc: %d\n" , rc);
Quoted 3 lines
return 1;
}Don't we also need to initialise rc to 0? It seems to me that it may be used uninitialised also inside of if(check_host)...
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 13 lines · Dario Faggioli
Quoted 11 lines · Wei Liu
tools/libxl/xl_cmdimpl.c +1
-1@@ -5473,7 +5473,8 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host) if (rc) return 1; } - if (libxl_cpu_bitmap_alloc(ctx, &cpumap, max_vcpus)) { + rc = libxl_cpu_bitmap_alloc(ctx, &cpumap, max_vcpus);
Quoted 8 lines
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +1
-0+ if (rc) { fprintf(stderr, "libxl_cpu_bitmap_alloc failed, rc: %d\n", rc);return 1;
}Don't we also need to initialise rc to 0? It seems to me that it may be used uninitialised also inside of
if(check_host)...
Looks like it, a separate issue though.
Don't initialise rc to 0, add a suitable else though.
Quoted 4 lines
Regards,
Dario
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 26 lines · Ian Campbell
Quoted 16 lines · Dario Faggioli
Quoted 14 lines · Wei Liu
tools/libxl/xl_cmdimpl.c +0
-0@@ -5473,7 +5473,8 @@ static int vcpuset(uint32_t domid, constchar*
nr_vcpus, intcheck_host)if (rc) return 1; }tools/libxl/xl_cmdimpl.c +2
-1-if (libxl_cpu_bitmap_alloc (ctx, &cpumap, max_vcpus)) { + rc =libxl_cpu_bitmap_alloc (ctx, &cpumap, max_vcpus); +if (rc) { fprintf(stderr, "libxl_cpu_bitmap_alloc failed, rc:Quoted 8 lines
Quoted 5 lines
%d\n",
rc); return 1; }Don't we also need to initialise rc to 0? It seems to me that it may be
used uninitialised also inside ofif(check_host)...
Quoted 2 lines
Looks like it, a separate issue though.
The compiler is not spotting it again, though (just as a side note).
Quoted 2 lines
Don't initialise rc to 0, add a suitable else though.
Yeah, sure, I figured that out after having sent the mail. I'll send a patch.
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 8 lines · Wei Liu
In
5b725e56(xl: improve return and exit codes of vcpu related functions), the return value oflibxl_cpu_bitmap_allocwas not stored in rc anymore. Yet the subsequent fprintf still used that.Reinstate the original implementation, that is, to store return value of
libxl_cpu_bitmap_allocin rc before using rc.Signed-off-by Wei Liu <[email protected]>
Acked + applied.