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

Re: [PATCH] xen/arm: traps: fix MISRA C 2012 Rule 8.7 violation


  • To: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Mon, 4 Jul 2022 07:41:20 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=7UPOhzPV33OghZIqesvi+kHzrRT/L2wAe/j2XuIUoak=; b=Dc9P4xjyQiyLWbV1XskyKTHYuovpyc3YdysMMO1pqRwYnVH6Y8YWAqEL8seujq9Iji9KXAA+EvEkXwL0yH6YC/e+7gRzcKB2GNM4quk4eqON6T3Um0dJUPrzzsaZGMnFG+OJn8CcaRYudhpMe5OLAOqYPggJE2+huDB9755jCJtsb5Dv7MsTMsvquwZWpwyLMXzZACTSHRTpNKSZ6fBI8z644J4rJBU2IShpEggXNBxTSqmzKC4wnqzsNKai1dOcARda0WxGTJjKWTDIk2Xqt67BvsTTRwmvoCZ8LWh0+vpNa8bC1Wm8jVF8W0B3y34IYo1D6X5aD2LUgwBrETTbmw==
  • 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=7UPOhzPV33OghZIqesvi+kHzrRT/L2wAe/j2XuIUoak=; b=IcVrKMhfBOgC6vjDwnx7xiAQNqPj8F2165gMujuLtpckLR28CcDUPS+g2SdohrnBq9KubF7BrNTu4HWT9TTuiIyjQcpCGT3DOinvaq4JMZhZ8+bXNkIzNCDBXMQnjOUypPZLuR2iLYa53exCuOGt1oXN21B0Elnw421acFivI68pZ7zgajoyVhrDZUHfs+rWZsAXArnlLaMZDuKtIF76RD5I5DHWNawvlI35+W4g6K7j0xUT2dN6fgxHBv9dg1kO1cKENZicLtDlE3MehyjgroGSjcprme5gfKWm2TBJo99DNGOiSI6uAR+3px+8rDend9YTqwT+5HLbg23T3LlK+Q==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=HlCJhP5afByl/2EQVFqQ+/tdEB62vei1sR9iP5kCvyUlPgBnCmvBY/WBcyJgpaqnIM2h1VmoUOhtTKbvXXsOw+xLOtIn5YoEvybbzrbj7paVVrK6Y7Jq3QbmJdfqnOadelvCdKxtzhfNY8WnOkYMWXFS5pFyUsdg5JsR4szIvcK7VF/3h8kElpVKI+ShOHqy7lob2+NcQBY3nptFsCOEA1h3EhDKxSLCk4VkXAmtI2SqkYH2/paEi84eA0XY2gTcAb8smJE9WMWxwOilIRWpLeX7EyYECvFKgVv4p1IJDzft4/cdM5l/SZZxyG5unjQRYGbo03THY/X/cFPBJaCfLQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUM4T7afCwwKOohvnvwbJ0WbM0EAWpclP7tkfNY1UqsErOiFwpml0MTTnUrMvfDIw4TgmBdugEvpVEQRi+FFv9AZA36EyaUv9l7wInYZWVT4oJWZtiYAHHnkaKuorEOKIQtxQkqZn1TOgtcOo/QBJRpf2Ebu60hsRXuGcV4zRf7D6iqRfhaOqfaHgbO924Rdgty3hhi8581IfJ+z9jSwJ2mP8tXWFpm8ghCAJ36p65vSMd8gDrju36KCtSncApugA8E+ZmE0XTp26eebmxWvkJCAJcJxLTS6YVS36bG8gofqZz7QQTiYGiIYxbpoi79Q2TN7epXqacBLAqWzCltiSg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 04 Jul 2022 07:41:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYj3bjMrWoDl4sYkqZXzEqwsl1S61t0/kA
  • Thread-topic: [PATCH] xen/arm: traps: fix MISRA C 2012 Rule 8.7 violation

Hi Xenia,

> On 4 Jul 2022, at 08:22, Xenia Ragiadakou <burzalodowa@xxxxxxxxx> wrote:
> 
> The functions show_registers() and show_stack() are referenced only in 
> traps.c.
> Change their linkage from external to internal by adding the storage-class
> specifier static to their definitions and by removing show_registers() from
> asm/processor.h header file.
> 
> Also, this patch resolves a MISRA C 2012 Rule 8.4 violation warning about the
> function show_stack().
> 
> Signed-off-by: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>
> ---
> I am not 100% sure about this patch.
> I think show_stack() should be declared the same way as show_registers().
> So either both of them will be declared with external linkage or both of them
> will be declared with internal linkage.

I think that those 2 should be declared with external linkage with a comment
explaining why they are. For me those are useful when developing or debugging
and I sometime call those to force dumping the status.
So I would vote to keep the external linkage.

> I decided to declare both of them static because they are referenced only in
> traps.c but I could have, also, add the declaration of show_stack() in
> asm/processor.h header instead. Rule 8.7 is advisory.

As said I would vote for external linkage here but would be nice to have other
developers view on this.

Cheers
Bertrand

> 
> xen/arch/arm/include/asm/processor.h | 1 -
> xen/arch/arm/traps.c                 | 4 ++--
> 2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/arm/include/asm/processor.h 
> b/xen/arch/arm/include/asm/processor.h
> index 4188ec6bfb..75c680ae9a 100644
> --- a/xen/arch/arm/include/asm/processor.h
> +++ b/xen/arch/arm/include/asm/processor.h
> @@ -558,7 +558,6 @@ extern register_t __cpu_logical_map[];
> void panic_PAR(uint64_t par);
> 
> void show_execution_state(const struct cpu_user_regs *regs);
> -void show_registers(const struct cpu_user_regs *regs);
> //#define dump_execution_state() 
> run_in_exception_handler(show_execution_state)
> #define dump_execution_state() WARN()
> 
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 785f2121d1..9398ceeed5 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -931,7 +931,7 @@ static void _show_registers(const struct cpu_user_regs 
> *regs,
>     printk("\n");
> }
> 
> -void show_registers(const struct cpu_user_regs *regs)
> +static void show_registers(const struct cpu_user_regs *regs)
> {
>     struct reg_ctxt ctxt;
>     ctxt.sctlr_el1 = READ_SYSREG(SCTLR_EL1);
> @@ -1146,7 +1146,7 @@ static void show_trace(const struct cpu_user_regs *regs)
>     printk("\n");
> }
> 
> -void show_stack(const struct cpu_user_regs *regs)
> +static void show_stack(const struct cpu_user_regs *regs)
> {
>     register_t *stack = STACK_BEFORE_EXCEPTION(regs), addr;
>     int i;
> -- 
> 2.34.1
> 




 


Rackspace

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