From: Konrad Rzeszutek Wilk Subject: [PATCH RFC 06/14] libxl: Fix xc_pm API calls to return negative error and stash error in errno. Date: Fri, 13 Mar 2015 15:31:15 -0400 Message-ID: <1426275083-8454-7-git-send-email-konrad.wilk@oracle.com> References: <1426275083-8454-1-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YWVJO-0006hK-0b for xen-devel@lists.xenproject.org; Fri, 13 Mar 2015 19:31:58 +0000 In-Reply-To: <1426275083-8454-1-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, wei.liu2@citrix.com Cc: Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org Oddly enough the user of this API did the right thing - check for return being negative and used 'errno' for the real error. Signed-off-by: Konrad Rzeszutek Wilk --- tools/libxc/xc_pm.c | 54 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/tools/libxc/xc_pm.c b/tools/libxc/xc_pm.c index e4e0fb9..5a7148e 100644 --- a/tools/libxc/xc_pm.c +++ b/tools/libxc/xc_pm.c @@ -51,8 +51,10 @@ int xc_pm_get_pxstat(xc_interface *xch, int cpuid, struct xc_px_stat *pxpt) int max_px, ret; if ( !pxpt->trans_pt || !pxpt->pt ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } if ( (ret = xc_pm_get_max_px(xch, cpuid, &max_px)) != 0) return ret; @@ -219,8 +221,10 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid, if ( (!user_para->affected_cpus) || (!user_para->scaling_available_frequencies) || (!user_para->scaling_available_governors) ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } if ( xc_hypercall_bounce_pre(xch, affected_cpus) ) goto unlock_1; if ( xc_hypercall_bounce_pre(xch, scaling_available_frequencies) ) @@ -293,8 +297,10 @@ int xc_set_cpufreq_gov(xc_interface *xch, int cpuid, char *govname) char *scaling_governor = sysctl.u.pm_op.u.set_gov.scaling_governor; if ( !xch || !govname ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } sysctl.cmd = XEN_SYSCTL_pm_op; sysctl.u.pm_op.cmd = SET_CPUFREQ_GOV; sysctl.u.pm_op.cpuid = cpuid; @@ -310,8 +316,10 @@ int xc_set_cpufreq_para(xc_interface *xch, int cpuid, DECLARE_SYSCTL; if ( !xch ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } sysctl.cmd = XEN_SYSCTL_pm_op; sysctl.u.pm_op.cmd = SET_CPUFREQ_PARA; sysctl.u.pm_op.cpuid = cpuid; @@ -327,8 +335,10 @@ int xc_get_cpufreq_avgfreq(xc_interface *xch, int cpuid, int *avg_freq) DECLARE_SYSCTL; if ( !xch || !avg_freq ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } sysctl.cmd = XEN_SYSCTL_pm_op; sysctl.u.pm_op.cmd = GET_CPUFREQ_AVGFREQ; sysctl.u.pm_op.cpuid = cpuid; @@ -392,8 +402,10 @@ int xc_get_cpuidle_max_cstate(xc_interface *xch, uint32_t *value) DECLARE_SYSCTL; if ( !xch || !value ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } sysctl.cmd = XEN_SYSCTL_pm_op; sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_max_cstate; sysctl.u.pm_op.cpuid = 0; @@ -409,8 +421,10 @@ int xc_set_cpuidle_max_cstate(xc_interface *xch, uint32_t value) DECLARE_SYSCTL; if ( !xch ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } sysctl.cmd = XEN_SYSCTL_pm_op; sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_set_max_cstate; sysctl.u.pm_op.cpuid = 0; @@ -424,8 +438,10 @@ int xc_enable_turbo(xc_interface *xch, int cpuid) DECLARE_SYSCTL; if ( !xch ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } sysctl.cmd = XEN_SYSCTL_pm_op; sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_enable_turbo; sysctl.u.pm_op.cpuid = cpuid; @@ -437,8 +453,10 @@ int xc_disable_turbo(xc_interface *xch, int cpuid) DECLARE_SYSCTL; if ( !xch ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } sysctl.cmd = XEN_SYSCTL_pm_op; sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_disable_turbo; sysctl.u.pm_op.cpuid = cpuid; -- 2.1.0