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

Re: [XEN PATCH] xen/set_{c,p}x_pminfo: address violations od MISRA C:2012 Rule 8.3


  • To: Federico Serafini <federico.serafini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 27 Oct 2023 15:57:06 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HJiV3slNr0tHCJXEI3X61r4zXwykuCqSO5AgES5BSgU=; b=bbe1tpC4bbMUqlj3m+PEijNfyXCyCFerFPq4BK/Fhu3mlEzx61f2E8j5XVl8ndPeSNTU+h2qVyKPapHqGwQ7fuOQPcUkqdJR3XHxzXBTKfeWYJeNSy6rxUooCtPu7c0s/YcH0QMxZwzOLlEEkoGpojv1jZDLiikbcs+njjgBpHzOrw50xxauCDJwgCvPDmtO6n7INpfnd62F+zbRF1Xw4fGWxrVoijRIv2qMrLU44A4RCHlw1w+JwO2nRkM+3ca8ItwtLjLuGFm4n+CkThpbotqZOS+OTififjK5PqZ70emmeD/DGfydglcqS+HKAXt1qsxdAFmnT4VxI8ODYT8ASw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MCA0ZPwcD8upIDKt3vrObhwymDi0BoTkWo74RmuVCnwtdFQ17rU2paqyhZZvV72cF8vSwwgpL8WtsW9OmsJvKtu67jcPXkiygftk8DxVX1x3+mJAxEmOh46WE+kqFacL6noq+tE5bFxxq2Ptt8Dm5Fhj9eREjIy/6y5+yyjEBJ2plSXoIvqIOYM9/F1lwvFcM9aN/OU/d8VAUmWUGpxcc4bmeNtAu+sMVtqbRNPcmr4ywO+eHHh2GWSE1UV1vGOZt8ffMJr5YZbVJp/4s3vaIphpdKRHBBZeP3m8Da/2PZY+I58mNVPAGwLLHL8mKbAuaDw9WwisNsRE89smUW34Dg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 27 Oct 2023 13:57:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.10.2023 14:09, Federico Serafini wrote:
> --- a/xen/drivers/cpufreq/cpufreq.c
> +++ b/xen/drivers/cpufreq/cpufreq.c
> @@ -457,14 +457,14 @@ static void print_PPC(unsigned int platform_limit)
>      printk("\t_PPC: %d\n", platform_limit);
>  }
>  
> -int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance 
> *dom0_px_info)
> +int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *perf)
>  {
>      int ret=0, cpuid;
>      struct processor_pminfo *pmpt;
>      struct processor_performance *pxpt;
>  
>      cpuid = get_cpu_id(acpi_id);
> -    if ( cpuid < 0 || !dom0_px_info)
> +    if ( ( cpuid < 0 ) || !perf)

I don't see the need for the new pair of parentheses here, but if you
add such, please don't violate style.

> @@ -488,21 +488,21 @@ int set_px_pminfo(uint32_t acpi_id, struct 
> xen_processor_performance *dom0_px_in
>      pmpt->acpi_id = acpi_id;
>      pmpt->id = cpuid;
>  
> -    if ( dom0_px_info->flags & XEN_PX_PCT )
> +    if ( perf->flags & XEN_PX_PCT )
>      {
>          /* space_id check */
> -        if (dom0_px_info->control_register.space_id != 
> -            dom0_px_info->status_register.space_id)
> +        if ( perf->control_register.space_id !=
> +             perf->status_register.space_id )
>          {
>              ret = -EINVAL;
>              goto out;
>          }
>  
>          memcpy ((void *)&pxpt->control_register,
> -                (void *)&dom0_px_info->control_register,
> +                (void *)&perf->control_register,
>                  sizeof(struct xen_pct_register));
>          memcpy ((void *)&pxpt->status_register,
> -                (void *)&dom0_px_info->status_register,
> +                (void *)&perf->status_register,
>                  sizeof(struct xen_pct_register));
>  
>          if ( cpufreq_verbose )
> @@ -512,69 +512,67 @@ int set_px_pminfo(uint32_t acpi_id, struct 
> xen_processor_performance *dom0_px_in
>          }
>      }
>  
> -    if ( dom0_px_info->flags & XEN_PX_PSS ) 
> +    if ( perf->flags & XEN_PX_PSS )
>      {
>          /* capability check */
> -        if (dom0_px_info->state_count <= 1)
> +        if (perf->state_count <= 1)

Since you're adjusting style elsewhere, would you mind adding the missing
blanks here as well?

>          {
>              ret = -EINVAL;
>              goto out;
>          }
>  
>          if ( !(pxpt->states = xmalloc_array(struct xen_processor_px,
> -                        dom0_px_info->state_count)) )
> +                                            perf->state_count)) )
>          {
>              ret = -ENOMEM;
>              goto out;
>          }
> -        if ( copy_from_guest(pxpt->states, dom0_px_info->states,
> -                             dom0_px_info->state_count) )
> +        if ( copy_from_guest(pxpt->states, perf->states, perf->state_count) )
>          {
>              ret = -EFAULT;
>              goto out;
>          }
> -        pxpt->state_count = dom0_px_info->state_count;
> +        pxpt->state_count = perf->state_count;
>  
>          if ( cpufreq_verbose )
>              print_PSS(pxpt->states,pxpt->state_count);
>      }
>  
> -    if ( dom0_px_info->flags & XEN_PX_PSD )
> +    if ( perf->flags & XEN_PX_PSD )
>      {
>          /* check domain coordination */
> -        if (dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_ALL &&
> -            dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_ANY &&
> -            dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_HW)
> +        if (perf->shared_type != CPUFREQ_SHARED_TYPE_ALL &&
> +            perf->shared_type != CPUFREQ_SHARED_TYPE_ANY &&
> +            perf->shared_type != CPUFREQ_SHARED_TYPE_HW)

Same here then?

Jan



 


Rackspace

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