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

Re: Address MISRA C:2012 Rule 8.4


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 4 Aug 2023 13:39:38 +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=lN9SFW9g/Qx3UKEHTnyDh2ynuN5d2QJ+aszhumNIb/U=; b=FDVrdUsmsJZqsOK39cxaUD2E1HZIW/eksYW7KW+UpBM5xYGzz/nlqXz7Yc19FyMCNl+RNTjPzYUShhojnx6hzkJXVpyTs7yKWVd7vkqZst84Ucgc1rzQX6Y0DFZetKz3AzA5A0LlRzCahF5GRm6sA4dEoKzuwBdwCbRd/v0PS43HKNJDxOeS18REp9M5Xd8e+qIoAIZQH8Z7YlG9dqXEw4PxPBnamh/nUpsFoNno+Sz6kS20zAp25Mefp7ATLiBfEYotYAlONySjmbcGCQQquOFGx5spn1d9P+IXUbHcxOYEhSM65Ki9QoN4kxm7eNB5UA2JJEpw6qn/CjbysMiZNA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nqcapm3KGkpf64TDOmb0PdRfdKBMDX4bBP3TAQDNu9+Y5EC2DxAmqDb78HgsYkQw7UYFSnRhh4VR4ODbm3DFRw5qYo6uyjqlwC9jDqxdI/ToLi12SF4FS6x9jKpGgYPtj/SMlMBUFVH8QydfkpfpLrAABf1GZ7vf47O90tjmdKapF9N2S6faT2zWp2H8xAjN+brEh/rlJhG1VCit4CV5rdcvkrZLLU8DkvmMfdZ7VPNfRs1gMOnBg/Ym7b7vDbrWVdic1xY+CuOZcQ6HrJp987axrGOy2lFst6wG3RLKc6tSSxADjD+KFOA/gWuNGvBlpCPNok5f/o/9jUQLko54xQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, xenia.ragiadakou@xxxxxxx, Ayan Kumar Halder <ayankuma@xxxxxxx>, consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Fri, 04 Aug 2023 11:39:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 04.08.2023 11:47, Nicola Vetrini wrote:
> Upon further examination, I identified the following patterns:
> 
> 1. Functions defined in .c called only from asm code (e.g., the already 
> mentioned __start_xen)
> 2. Functions/variables declared in a .h, defined in a .c that does not 
> include the .h with the declaration
> (e.g., 'fill_console_start_info' is defined in 'xen/drivers/vga.c', 
> declared in 'xen/include/xen/console.h' which is not visible when 
> compiling the .c).
> 3. Variables that are either extern or not, such as 'acpi_gbl_FADT' in 
> 'xen/include/acpi/acglobal.h', depending on
>     DEFINE_ACPI_GLOBALS
> 
> Below are the proposed resolution strategies:
> 
> 1. I would advise to add the declaration in the relative .h, to support 
> automatic consistency checks with the
>     implementation and a quick reference when touching the asm.

That'll need discussing first.

> 2. To comply with the rule, the header with the declaration should be 
> included. Also note that there are some
>     corner cases, such as 'get_sec', which is used in 'cper.h' without 
> including 'time.h' (which should gain a
>     declaration for it).

This one of course wants fixing wherever found.

> 3. One possible resolution pattern is including 'acglobal.h' twice 
> (either directly or indirectly trough acpi.h, if
>     the latter does not cause other issues) like so:
> 
>     (assuming DEFINE_ACPI_GLOBALS is undefined here)
>     #include "acglobal.h"
>     #define DEFINE_ACPI_GLOBALS
>     #include  "acglobal.h"
> 
>    this way, the rule is followed properly, though it's not the prettiest 
> pattern and also clashes with the objectives
>    of D4.10 ("Precautions shall be taken in order to prevent the contents 
> of a header file being included
>    more than once"), but then a motivated exception is allowed there.

Not really sure about this one.

Jan



 


Rackspace

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