From patchwork Fri Sep 30 12:04:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9358085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 526A860757 for ; Fri, 30 Sep 2016 12:07:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F2A129FD2 for ; Fri, 30 Sep 2016 12:07:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3070229FD9; Fri, 30 Sep 2016 12:07:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0303E29FD2 for ; Fri, 30 Sep 2016 12:07:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpwZ7-0007Yi-1Z; Fri, 30 Sep 2016 12:05:21 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpwZ5-0007Ya-Js for xen-devel@lists.xenproject.org; Fri, 30 Sep 2016 12:05:19 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 83/B8-28497-EF45EE75; Fri, 30 Sep 2016 12:05:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEKsWRWlGSWpSXmKPExsXitHRDpO7fkHf hBkueall83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBm79jsWnLSt6Go/yNrA+Meqi5GTQ0IgRGLn z+ksIDavgKHEsWmXmUFsYYE4iYXf94PF2QQMJN7s2MsKYosIaEu8WLWODcRmFiiU+N66CKieg 4NFQFVi0wQhkDCngKPEkndfwEqEBI4ySpz8LANi8wtIStz68pEZorVaYtPZ3WwQJ2hL9Oz9wQ xxgqDEyZlPWCB61SRmzL3MCjJeQoBb4m+3/QRG/llIumch6YCIO0g8n9TADGFrSrRu/80OYWt LLFv4GioeIvHuwGVWCFtRYkr3Q6iaWInzn7oZIWxbiXXr3kPNtJHYdHUBVFxeYvvbOcwLGLlX MWoUpxaVpRbpGhrqJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIExg8DEOxg/LQs4 BCjJAeTkiiv7NG34UJ8SfkplRmJxRnxRaU5qcWHGDU4OAQmnJ07nUmKJS8/L1VJglcCGKdCgk Wp6akVaZk5wAiHKZXg4FES4RUFSfMWFyTmFmemQ6ROMSpKifPygyQEQBIZpXlwbbCkcolRVkq YlxHoKCGegtSi3MwSVPlXjOIcjErCvAIgU3gy80rgpr8CWswEtDj/6BuQxSWJCCmpBsbIBucq Cf0Nwcwt75JU4j+/5NeWmV3A8eXh2c1P+Gd87+Jq27aY6fclx8Tn75qcl15L7beyWiDnsLu3z iZ8Ej+z7ofuHwssH3/P8E3yf34qaH3udZcHn+1stqYxudv9Z9j/w+xIe++5E+HMzaIvZ5lOnz ClTJl/+srpO8XDlBwZnky5bm/3c48SS3FGoqEWc1FxIgCPlge+JQMAAA== X-Env-Sender: prvs=074d4ead7=dario.faggioli@citrix.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1475237116!53017380!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46750 invoked from network); 30 Sep 2016 12:05:17 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 30 Sep 2016 12:05:17 -0000 X-IronPort-AV: E=Sophos;i="5.31,272,1473120000"; d="asc'?scan'208";a="381663126" Message-ID: <1475237087.5315.74.camel@citrix.com> From: Dario Faggioli To: Ian Jackson Date: Fri, 30 Sep 2016 14:04:47 +0200 In-Reply-To: <22510.15692.455184.207639@mariner.uk.xensource.com> References: <147520253247.22544.10673844222866363947.stgit@Solace.fritz.box> <147520405481.22544.7998206786104494657.stgit@Solace.fritz.box> <22510.15692.455184.207639@mariner.uk.xensource.com> Organization: Citrix Inc. X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) MIME-Version: 1.0 X-DLP: MIA1 Cc: George Dunlap , xen-devel@lists.xenproject.org, Wei Liu Subject: Re: [Xen-devel] [PATCH v2 08/10] libxl: fix coding style of credit1 parameters related functions X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 2016-09-30 at 11:24 +0100, Ian Jackson wrote: > Dario Faggioli writes ("[PATCH v2 08/10] libxl: fix coding style of > credit1 parameters related functions"): > >  int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid, > >                                    libxl_sched_credit_params > > *scinfo) > >  { > >      struct xen_sysctl_credit_schedule sparam; > > -    int rc=0; > > +    int r, rc; > ... > > > >   > >      scinfo->tslice_ms = sparam.tslice_ms; > >      scinfo->ratelimit_us = sparam.ratelimit_us; > >   > > + out: > >      GC_FREE; > > -    return 0; > > +    return rc; > > I think this is missing an assignment > >   rc = 0; > > on the successful exit path, just before out.  Am I wrong ? > Indeed it's missing. It was not necessary in v1 of this patch, so I must have failed to notice that it was, when splitting that in two. Sorry. Not sure how to proceed, so I'm attaching an updated version of the patch to this email. Thanks and Regards, Dario From: Dario Faggioli libxl: fix coding style of credit1 parameters related functions More specifically, the the error handling path is made compliant with libxl's codying style. No functional change intended. Signed-off-by: Dario Faggioli --- Cc: Ian Jackson Cc: Wei Liu Cc: George Dunlap --- Changes from v2: * add a missing 'rc = 0', as noted during review. Changes from v1: * new patch, containing only the coding style changes from what was patch 14 in v1. diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index a46b827..d2552f9 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5260,65 +5260,69 @@ int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid, libxl_sched_credit_params *scinfo) { struct xen_sysctl_credit_schedule sparam; - int rc; + int r, rc; GC_INIT(ctx); - rc = xc_sched_credit_params_get(ctx->xch, poolid, &sparam); - if (rc != 0) { - LOGE(ERROR, "getting sched credit param"); - GC_FREE; - return ERROR_FAIL; + r = xc_sched_credit_params_get(ctx->xch, poolid, &sparam); + if (r < 0) { + LOGE(ERROR, "getting Credit scheduler parameters"); + rc = ERROR_FAIL; + goto out; } scinfo->tslice_ms = sparam.tslice_ms; scinfo->ratelimit_us = sparam.ratelimit_us; + rc = 0; + out: GC_FREE; - return 0; + return rc; } int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid, libxl_sched_credit_params *scinfo) { struct xen_sysctl_credit_schedule sparam; - int rc=0; + int r, rc; GC_INIT(ctx); if (scinfo->tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN || scinfo->tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX) { LOG(ERROR, "Time slice out of range, valid range is from %d to %d", XEN_SYSCTL_CSCHED_TSLICE_MIN, XEN_SYSCTL_CSCHED_TSLICE_MAX); - GC_FREE; - return ERROR_INVAL; + rc = ERROR_INVAL; + goto out; } if (scinfo->ratelimit_us < XEN_SYSCTL_SCHED_RATELIMIT_MIN || scinfo->ratelimit_us > XEN_SYSCTL_SCHED_RATELIMIT_MAX) { LOG(ERROR, "Ratelimit out of range, valid range is from %d to %d", XEN_SYSCTL_SCHED_RATELIMIT_MIN, XEN_SYSCTL_SCHED_RATELIMIT_MAX); - GC_FREE; - return ERROR_INVAL; + rc = ERROR_INVAL; + goto out; } if (scinfo->ratelimit_us > scinfo->tslice_ms*1000) { LOG(ERROR, "Ratelimit cannot be greater than timeslice"); - GC_FREE; - return ERROR_INVAL; + rc = ERROR_INVAL; + goto out; } sparam.tslice_ms = scinfo->tslice_ms; sparam.ratelimit_us = scinfo->ratelimit_us; - rc = xc_sched_credit_params_set(ctx->xch, poolid, &sparam); - if ( rc < 0 ) { - LOGE(ERROR, "setting sched credit param"); - GC_FREE; - return ERROR_FAIL; + r = xc_sched_credit_params_set(ctx->xch, poolid, &sparam); + if ( r < 0 ) { + LOGE(ERROR, "Setting Credit scheduler parameters"); + rc = ERROR_FAIL; + goto out; } scinfo->tslice_ms = sparam.tslice_ms; scinfo->ratelimit_us = sparam.ratelimit_us; + rc = 0; + out: GC_FREE; - return 0; + return rc; } static int sched_credit2_domain_get(libxl__gc *gc, uint32_t domid,