[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE]



turning scheduling related functions xl exit codes towards using the
EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary numbers
or libxl return codes.

Signed-off-by: Harmandeep Kaur <write.harmandeep@xxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c | 67 ++++++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 34 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 365798b..c215c14 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -5851,13 +5851,13 @@ static int sched_credit_domain_output(int domid)
 
     if (domid < 0) {
         printf("%-33s %4s %6s %4s\n", "Name", "ID", "Weight", "Cap");
-        return 0;
+        return EXIT_SUCCESS;
     }
 
     libxl_domain_sched_params_init(&scinfo);
     rc = sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo);
     if (rc)
-        return rc;
+        return EXIT_FAILURE;
     domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %6d %4d\n",
         domname,
@@ -5866,7 +5866,7 @@ static int sched_credit_domain_output(int domid)
         scinfo.cap);
     free(domname);
     libxl_domain_sched_params_dispose(&scinfo);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_credit_pool_output(uint32_t poolid)
@@ -5887,7 +5887,7 @@ static int sched_credit_pool_output(uint32_t poolid)
                scparam.ratelimit_us);
     }
     free(poolname);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_credit2_domain_output(
@@ -5899,13 +5899,13 @@ static int sched_credit2_domain_output(
 
     if (domid < 0) {
         printf("%-33s %4s %6s\n", "Name", "ID", "Weight");
-        return 0;
+        return EXIT_SUCCESS;
     }
 
     libxl_domain_sched_params_init(&scinfo);
     rc = sched_domain_get(LIBXL_SCHEDULER_CREDIT2, domid, &scinfo);
     if (rc)
-        return rc;
+        return EXIT_FAILURE;
     domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %6d\n",
         domname,
@@ -5913,7 +5913,7 @@ static int sched_credit2_domain_output(
         scinfo.weight);
     free(domname);
     libxl_domain_sched_params_dispose(&scinfo);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_rtds_domain_output(
@@ -5925,13 +5925,14 @@ static int sched_rtds_domain_output(
 
     if (domid < 0) {
         printf("%-33s %4s %9s %9s\n", "Name", "ID", "Period", "Budget");
-        return 0;
+        return EXIT_SUCCESS;
     }
 
     libxl_domain_sched_params_init(&scinfo);
     rc = sched_domain_get(LIBXL_SCHEDULER_RTDS, domid, &scinfo);
     if (rc)
-        goto out;
+        libxl_domain_sched_params_dispose(&scinfo);
+        return EXIT_FAILURE;
 
     domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %9d %9d\n",
@@ -5940,10 +5941,8 @@ static int sched_rtds_domain_output(
         scinfo.period,
         scinfo.budget);
     free(domname);
-
-out:
     libxl_domain_sched_params_dispose(&scinfo);
-    return rc;
+    return EXIT_SUCCESS;
 }
 
 static int sched_rtds_pool_output(uint32_t poolid)
@@ -5954,7 +5953,7 @@ static int sched_rtds_pool_output(uint32_t poolid)
     printf("Cpupool %s: sched=RTDS\n", poolname);
 
     free(poolname);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_default_pool_output(uint32_t poolid)
@@ -5965,7 +5964,7 @@ static int sched_default_pool_output(uint32_t poolid)
     printf("Cpupool %s:\n",
            poolname);
     free(poolname);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_domain_output(libxl_scheduler sched, int (*output)(int),
@@ -5981,14 +5980,14 @@ static int sched_domain_output(libxl_scheduler sched, 
int (*output)(int),
         if (libxl_cpupool_qualifier_to_cpupoolid(ctx, cpupool, &poolid, NULL) 
||
             !libxl_cpupoolid_is_valid(ctx, poolid)) {
             fprintf(stderr, "unknown cpupool \'%s\'\n", cpupool);
-            return -ERROR_FAIL;
+            return EXIT_FAILURE;
         }
     }
 
     info = libxl_list_domain(ctx, &nb_domain);
     if (!info) {
         fprintf(stderr, "libxl_list_domain failed.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
@@ -6016,7 +6015,7 @@ static int sched_domain_output(libxl_scheduler sched, int 
(*output)(int),
 
     libxl_cpupoolinfo_list_free(poolinfo, n_pools);
     libxl_dominfo_list_free(info, nb_domain);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 /* 
@@ -6080,16 +6079,16 @@ int main_sched_credit(int argc, char **argv)
     if ((cpupool || opt_s) && (dom || opt_w || opt_c)) {
         fprintf(stderr, "Specifying a cpupool or schedparam is not "
                 "allowed with domain options.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (!dom && (opt_w || opt_c)) {
         fprintf(stderr, "Must specify a domain.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (!opt_s && (opt_t || opt_r)) {
         fprintf(stderr, "Must specify schedparam to set schedule "
                 "parameter values.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (opt_s) {
@@ -6101,7 +6100,7 @@ int main_sched_credit(int argc, char **argv)
                                                      &poolid, NULL) ||
                 !libxl_cpupoolid_is_valid(ctx, poolid)) {
                 fprintf(stderr, "unknown cpupool \'%s\'\n", cpupool);
-                return -ERROR_FAIL;
+                return EXIT_FAILURE;
             }
         }
 
@@ -6110,7 +6109,7 @@ int main_sched_credit(int argc, char **argv)
         } else { /* Set scheduling parameters*/
             rc = sched_credit_params_get(poolid, &scparam);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
 
             if (opt_t)
                 scparam.tslice_ms = tslice;
@@ -6120,7 +6119,7 @@ int main_sched_credit(int argc, char **argv)
 
             rc = sched_credit_params_set(poolid, &scparam);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
         }
     } else if (!dom) { /* list all domain's credit scheduler info */
         return -sched_domain_output(LIBXL_SCHEDULER_CREDIT,
@@ -6144,11 +6143,11 @@ int main_sched_credit(int argc, char **argv)
             rc = sched_domain_set(domid, &scinfo);
             libxl_domain_sched_params_dispose(&scinfo);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
         }
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_sched_credit2(int argc, char **argv)
@@ -6180,11 +6179,11 @@ int main_sched_credit2(int argc, char **argv)
     if (cpupool && (dom || opt_w)) {
         fprintf(stderr, "Specifying a cpupool is not allowed with other "
                 "options.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (!dom && opt_w) {
         fprintf(stderr, "Must specify a domain.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (!dom) { /* list all domain's credit scheduler info */
@@ -6207,11 +6206,11 @@ int main_sched_credit2(int argc, char **argv)
             rc = sched_domain_set(domid, &scinfo);
             libxl_domain_sched_params_dispose(&scinfo);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
         }
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 /*
@@ -6256,15 +6255,15 @@ int main_sched_rtds(int argc, char **argv)
     if (cpupool && (dom || opt_p || opt_b)) {
         fprintf(stderr, "Specifying a cpupool is not allowed with "
                 "other options.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (!dom && (opt_p || opt_b)) {
         fprintf(stderr, "Must specify a domain.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (opt_p != opt_b) {
         fprintf(stderr, "Must specify period and budget\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (!dom) { /* list all domain's rt scheduler info */
@@ -6287,11 +6286,11 @@ int main_sched_rtds(int argc, char **argv)
             rc = sched_domain_set(domid, &scinfo);
             libxl_domain_sched_params_dispose(&scinfo);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
         }
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_domid(int argc, char **argv)
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.