Skip to contentSkip to conversation

xl: don't print out uninitialised rc

PATCH In review Wei Liu 2 participants 3 messages Nov 4, 2015

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 xl: don't print out uninitialised rc

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.

While it is trivial to reinstate the original implementation, xl's caller has no idea what a libxl error code is so printing out rc won't be that useful. Don't print out rc in that case.

---
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Dario Faggioli <[email protected]>
Cc: Harmandeep Kaur <[email protected]>

---
 tools/libxl/xl_cmdimpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +1 -1
index 2756d2f..6056344 100644
@@ -5474,7 +5474,7 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)
             return 1;
     }
     if (libxl_cpu_bitmap_alloc(ctx, &cpumap, max_vcpus)) {
-        fprintf(stderr, "libxl_cpu_bitmap_alloc failed, rc: %d\n", rc);
+        fprintf(stderr, "libxl_cpu_bitmap_alloc failed\n");
         return 1;
     }
     for (i = 0; i < max_vcpus; i++)
Signature · 1 line
2.1.4
#1 lore raw
Quoted 7 lines · Wei Liu

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.

While it is trivial to reinstate the original implementation, xl's caller has no idea what a libxl error code is so printing out rc won't be that useful.

I don't buy this I'm afraid. xl prints the libxl error code in lots of places and it is indeed useful for a person (e.g. a developer reading a bug report) since they can go and look the number up.

I'm not sure where "xl's caller" comes into it, since this is only about printing and not returning.

Quoted 25 lines

Don't print out rc in that case.

---
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Dario Faggioli <[email protected]>
Cc: Harmandeep Kaur <[email protected]>
---
 tools/libxl/xl_cmdimpl.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +1 -1
index 2756d2f..6056344 100644
@@ -5474,7 +5474,7 @@ static int vcpuset(uint32_t domid, const char*
 nr_vcpus, int check_host)
              return 1;
      }
      if (libxl_cpu_bitmap_alloc(ctx, &cpumap, max_vcpus)) {
-        fprintf(stderr, "libxl_cpu_bitmap_alloc failed, rc: %d\n", rc);
+        fprintf(stderr, "libxl_cpu_bitmap_alloc failed\n");
          return 1;
      }
Quoted 1 line

     for (i = 0; i < max_vcpus; i++)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#2 lore raw
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Wei Liu

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.

While it is trivial to reinstate the original implementation, xl's caller has no idea what a libxl error code is so printing out rc won't be that useful.

Quoted 7 lines

I don't buy this I'm afraid. xl prints the libxl error code in lots of places and it is indeed useful for a person (e.g. a developer reading a bug report) since they can go and look the number up.

I'm not sure where "xl's caller" comes into it, since this is only about printing and not returning.

So the original implementation it is -- I don't feel strong enough to argue for one way or another.

Wei.

Quoted 26 lines
Quoted 26 lines

Don't print out rc in that case.

---
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Dario Faggioli <[email protected]>
Cc: Harmandeep Kaur <[email protected]>
---
 tools/libxl/xl_cmdimpl.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +1 -1
index 2756d2f..6056344 100644
@@ -5474,7 +5474,7 @@ static int vcpuset(uint32_t domid, const char*
 nr_vcpus, int check_host)
              return 1;
      }
      if (libxl_cpu_bitmap_alloc(ctx, &cpumap, max_vcpus)) {
-        fprintf(stderr, "libxl_cpu_bitmap_alloc failed, rc: %d\n", rc);
+        fprintf(stderr, "libxl_cpu_bitmap_alloc failed\n");
          return 1;
      }

     for (i = 0; i < max_vcpus; i++)