From patchwork Wed Feb 24 12:53:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harmandeep Kaur X-Patchwork-Id: 8405991 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 81D72C0553 for ; Wed, 24 Feb 2016 12:57:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9025A20165 for ; Wed, 24 Feb 2016 12:57:09 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 864DF2011D for ; Wed, 24 Feb 2016 12:57:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYYxj-0008EE-5G; Wed, 24 Feb 2016 12:54:39 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYYxh-0008Cu-Jh for xen-devel@lists.xenproject.org; Wed, 24 Feb 2016 12:54:37 +0000 Received: from [193.109.254.147] by server-16.bemta-14.messagelabs.com id 7A/37-02863-C08ADC65; Wed, 24 Feb 2016 12:54:36 +0000 X-Env-Sender: write.harmandeep@gmail.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1456318474!14159073!1 X-Originating-IP: [209.85.192.194] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20735 invoked from network); 24 Feb 2016 12:54:35 -0000 Received: from mail-pf0-f194.google.com (HELO mail-pf0-f194.google.com) (209.85.192.194) by server-14.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 24 Feb 2016 12:54:35 -0000 Received: by mail-pf0-f194.google.com with SMTP id e127so915073pfe.3 for ; Wed, 24 Feb 2016 04:54:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7IZA5fzX5v51DpqCL8PSDorXIC6lL+V2KLrogswvKZs=; b=uVzt/SQCc3Vccf3taATiBtoPQIzOiBKQM6SvMj82Zn+WqE+6sYvo1IwMzKM4InRD0Y XTHo+E2DYZIr2DsEBcBj4KT4KNoGuoc5TVve8wIUouzwcePgn617mndCMPDj1hDfwOB+ WIho66Cx2Jxh0k+A9EeRi6aWIwK6VmMoZiKYgK/2zVkGQCkkQRR8z3aaV/P8ATEWTsXm 0lkb1Svp8jOiAVu6ty+omOJmspsPIfj0RZ1/bJKGHKFw9qr/LbqfrFVabCvIzc7vhtnX jIGmuLMF+OEKkRTv+xxK8ingkecdxUfEAqpy0how0aPo16h0DI+Pb00BPk8gAJQsRBdV ETpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7IZA5fzX5v51DpqCL8PSDorXIC6lL+V2KLrogswvKZs=; b=l+3qkVPDRVGXBT01a6P7KOnCe6dfXLxc0o/pT/ga/CtzAbtQxyfYqtXWstBECgbdBA 556UYwN0D8tCoYeZ6CiGJG0pxQNXoZY56rUxKyC4KAcfhh1CZndprM7IpcbFZOwynolX D/S+lg8FxooF1gsF/ML4ge8nm5bxKx/IXplqz+xGDICuBeC4gCNyhF2TxIbinYZzr8hR sGn+UppciS+6XPfIRyUAayZNxLcp1G2Ru7dL45uMd0R9rXZKahgm4V7+219tyHGxhPnQ /0Z+xAFjHVskBatHxB6LbOaljfpy5tA8gChFa494xmMvsmmgBN5WWBAGp4/mhEVTkO4W pRWQ== X-Gm-Message-State: AG10YOTJPgs93nNnD0+C84lo2lQmGlHEs2sGx/vwIwqpEsdlXGD82QD8w6Zy8N0CCQY61A== X-Received: by 10.98.67.153 with SMTP id l25mr54579548pfi.111.1456318473736; Wed, 24 Feb 2016 04:54:33 -0800 (PST) Received: from localhost.localdomain ([124.253.62.0]) by smtp.googlemail.com with ESMTPSA id t87sm5027294pfa.14.2016.02.24.04.54.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Feb 2016 04:54:33 -0800 (PST) From: Harmandeep Kaur To: xen-devel@lists.xenproject.org Date: Wed, 24 Feb 2016 18:23:25 +0530 Message-Id: <1456318407-3635-8-git-send-email-write.harmandeep@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456318407-3635-1-git-send-email-write.harmandeep@gmail.com> References: <1456318407-3635-1-git-send-email-write.harmandeep@gmail.com> Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, Harmandeep Kaur Subject: [Xen-devel] [PATCH 7/9] xl: Improve return and exit codes of main_create(), main_config_update(), main_sharing(), main_rename() and related functions. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Harmandeep Kaur --- tools/libxl/xl_cmdimpl.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 9d95b50..f7f7d7f 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -5001,7 +5001,7 @@ static void string_realloc_append(char **accumulate, const char *more) size_t morelen = strlen(more) + 1/*nul*/; if (oldlen > SSIZE_MAX || morelen > SSIZE_MAX - oldlen) { fprintf(stderr,"Additional config data far too large\n"); - exit(-ERROR_FAIL); + exit(EXIT_FAILURE); } *accumulate = xrealloc(*accumulate, oldlen + morelen); @@ -5076,7 +5076,7 @@ int main_create(int argc, char **argv) } else { help("create"); free(dom_info.extra_config); - return 2; + return EXIT_FAILURE; } } @@ -5095,11 +5095,11 @@ int main_create(int argc, char **argv) rc = create_domain(&dom_info); if (rc < 0) { free(dom_info.extra_config); - return -rc; + return EXIT_FAILURE; } free(dom_info.extra_config); - return 0; + return EXIT_SUCCESS; } int main_config_update(int argc, char **argv) @@ -5120,7 +5120,7 @@ int main_config_update(int argc, char **argv) if (argc < 2) { fprintf(stderr, "xl config-update requires a domain argument\n"); help("config-update"); - exit(1); + exit(EXIT_FAILURE); } fprintf(stderr, "WARNING: xl now has better capability to manage domain configuration, " @@ -5152,7 +5152,7 @@ int main_config_update(int argc, char **argv) } else { help("create"); free(extra_config); - return 2; + return EXIT_FAILURE; } } if (filename) { @@ -5161,25 +5161,25 @@ int main_config_update(int argc, char **argv) &config_data, &config_len); if (rc) { fprintf(stderr, "Failed to read config file: %s: %s\n", filename, strerror(errno)); - free(extra_config); return ERROR_FAIL; } + free(extra_config); return EXIT_FAILURE; } if (extra_config && strlen(extra_config)) { if (config_len > INT_MAX - (strlen(extra_config) + 2 + 1)) { fprintf(stderr, "Failed to attach extra configuration\n"); - exit(1); + exit(EXIT_FAILURE); } /* allocate space for the extra config plus two EOLs plus \0 */ config_data = realloc(config_data, config_len + strlen(extra_config) + 2 + 1); if (!config_data) { fprintf(stderr, "Failed to realloc config_data\n"); - exit(1); + exit(EXIT_FAILURE); } config_len += sprintf(config_data + config_len, "\n%s\n", extra_config); } } else { fprintf(stderr, "Config file not specified\n"); - exit(1); + exit(EXIT_FAILURE); } libxl_domain_config_init(&d_config); @@ -5195,7 +5195,7 @@ int main_config_update(int argc, char **argv) config_data, config_len); if (rc) { fprintf(stderr, "failed to update configuration\n"); - exit(1); + exit(EXIT_FAILURE); } } @@ -5203,7 +5203,7 @@ int main_config_update(int argc, char **argv) free(config_data); free(extra_config); - return 0; + return EXIT_SUCCESS; } static void button_press(uint32_t domid, const char *b) @@ -5772,7 +5772,7 @@ int main_sharing(int argc, char **argv) info = libxl_list_domain(ctx, &nb_domain); if (!info) { fprintf(stderr, "libxl_list_domain failed.\n"); - return 1; + return EXIT_FAILURE; } info_free = info; } else if (optind == argc-1) { @@ -5781,17 +5781,17 @@ int main_sharing(int argc, char **argv) if (rc == ERROR_DOMAIN_NOTFOUND) { fprintf(stderr, "Error: Domain \'%s\' does not exist.\n", argv[optind]); - return -rc; + return EXIT_FAILURE; } if (rc) { fprintf(stderr, "libxl_domain_info failed (code %d).\n", rc); - return -rc; + return EXIT_FAILURE; } info = &info_buf; nb_domain = 1; } else { help("sharing"); - return 2; + return EXIT_FAILURE; } sharing(info, nb_domain); @@ -5801,7 +5801,7 @@ int main_sharing(int argc, char **argv) else libxl_dominfo_dispose(info); - return 0; + return EXIT_SUCCESS; } static int sched_domain_get(libxl_scheduler sched, int domid, @@ -6374,10 +6374,10 @@ int main_rename(int argc, char **argv) domid = find_domain(dom); if (libxl_domain_rename(ctx, domid, common_domname, new_name)) { fprintf(stderr, "Can't rename domain '%s'.\n", dom); - return 1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } int main_trigger(int argc, char **argv)