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

Re: [XEN PATCH 2/4] x86/emulate: move a variable declaration to address MISRA C:2012 Rule 5.3


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 27 Jul 2023 17:06:20 +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=S190/nkthK0y/DeQv0OlSOhUH6hhPHvCDOj/hWEuRfQ=; b=LNJRKS/98y2jpT6GJZvoZ7jvVapu8f4WD+EggN5ZI7XcM9HJOmaDK5at7Df4DWUkWcKfbkU/VIXtEVQP3asm25tticlV3EXk+EWhCKkEYHGwO1nEvhI4JirX6+WZaFXN+KNgXesH4ZQJIMacVH+WXOWqdpyRvMkh/4GPLASlJFbek+KSvrS5wuikooOeoveoOa/UJUu9/OJN1jJ1bVyWlo85Re/pQgTF/7ipOk2RMPXrRxLzytDvcTHJmzHjcTGLh2k+BTM3yvMmQMA8QieepUmU1TiWnhx3e+3H2oYC0zDrh1++/GEbs+tsNSsOSj9BZoqgxXz0ySmfiINfW/4kPw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BATfU5EK254/ErXNuuUS8tDCxuhNP2IOfLA/y//g+FT7Lf1kDOBFUfLiLNYl268niSF/UiduA2dfbHK6GI4MIJarWPt/Zkv403IoNw4jndjSROWLZqp+QlL3a98WV71bW4rBLJMo+2qeoEEGGTFr5N/R8sfViyPGKaPAl3xBbsPVWYN0zsgmRxVJOmTfiw17NBX+ylXmBIilVH0f5YId7o/Vb38FcpL5WqFGAsliSVlrTjkJzD0H61NUKeNsNvZqju8Q0svIlqdNMDguSSTZ3y17dWJmFEqdIMDoPxPsN+TMmawobJqXbGsFdTpWYHw719T+4JW6/FgWkjHCTWWo1Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: sstabellini@xxxxxxxxxx, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, Paul Durrant <paul@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 27 Jul 2023 15:06:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.07.2023 12:48, Nicola Vetrini wrote:
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -2024,15 +2024,15 @@ static int cf_check hvmemul_rep_stos(
>  
>      switch ( p2mt )
>      {
> -        unsigned long bytes;
>          char *buf;
>  
>      default:
>          /* Allocate temporary buffer. */
>          for ( ; ; )
>          {
> -            bytes = *reps * bytes_per_rep;
> -            buf = xmalloc_bytes(bytes);
> +            unsigned long bytes_tmp;
> +            bytes_tmp = *reps * bytes_per_rep;
> +            buf = xmalloc_bytes(bytes_tmp);
>              if ( buf || *reps <= 1 )
>                  break;
>              *reps >>= 1;

This wants dealing with differently - the outer scope variable is unused
(only written to) afaics. Eliminating it will, aiui, address another
violation at the same time. And then the same in hvmemul_rep_movs(), just
that there the variable itself needs to survive. I guess I'll make a
patch ...

Jan



 


Rackspace

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