[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 10/14] ELF/notes: use pointer-to-const by default in ELFNOTE_...()
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Date: Tue, 22 Sep 2026 01:45:54 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=MPkawwD+HSAfDUsETDFv9ZVFdYkVi5OEd0ksNR02mWk=; b=N8AthuQrVBT1NiQ/Gj35VNIKB9orsZQMEdTnm2894ZMl1ooTb5/rmMyzUVAyvpTJRriYUnBL4fquSpXzA5u5lK9KKwdhdkkJErmkFT4lWShuFHMqIqyjWULxtZWvn8MSRw96wVlzjkup5ChbkEuclSjc0G6t+66+UMLiX/jlMHrQat0EyEKxKwnwNopU5lA+Yx0WQK1X5zKTL5ENfnMYR78ITG5r+Fd6Ok79Jet+nZAM270FnXIyKO8N0nZ31i+VyHN94Up6CrlF2bRitkFxzUkjzpmcZv+ATbiQR+aoyj/IUP+vWFpNkn7OZQqTnPPAZ+zClven2fMYwbAeymgzKg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h8A+e2xOEXN2W+H7ieUZzy+qMwjBNidLC4hbYn8pCcoOVUaXnBdOoll6L6gpDC8bcCzwlmVhSa3w9nfRsAbZrG1DZ2oQWwvpz3j4MCU6s1lIx/pytwuSsUhEaHxlpMM4kLNxQhHEoWQ4R5QXiJ3j3Vt5B7GQ4LhQGnDYODtSign+m2NZ0+2+yod4GJWTcoBOM+frSUVjR2F2y7dSy9VOEWucRiV4RnWsUA/Mybq2XKIjbjTU4VGt6t3oCtLhf68Nk/oNwzOuP2ktBa9+gC/1629qk9bBr6R+o+XauyOGx1USV7rLcCIO0YVjFIxbcSlJ5kHXo61G4mxpjSQ0JypOxw==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>
- Delivery-date: Tue, 22 Sep 2026 01:46:07 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHdOqU2Vkz5DOI+4USs/ahFyLHJfA==
- Thread-topic: [PATCH 10/14] ELF/notes: use pointer-to-const by default in ELFNOTE_...()
Hi Jan,
Jan Beulich <jbeulich@xxxxxxxx> writes:
> Not doing so results in a number of Misra rule 11.8 (casting away of
> const-ness) violations. We need to allow kexec to use pointer to non-
> const though, so provide a means to override the default.
>
> For ELFNOTE_NEXT() we can do better and simply re-apply the type of the
> incoming pointer.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>
> --- a/xen/common/kexec.c
> +++ b/xen/common/kexec.c
> @@ -6,6 +6,9 @@
> * - Magnus Damm <magnus@xxxxxxxxxxxxx>
> */
>
> +/* We're producing ELF notes here. */
> +#define ELFNOTE_CONST
Frankly, it feels backwards. When reading this line of code I am
assuming that you are adding constness to ELF notes because you are
defining ELFNOTE_CONST. And I had to check the elf.h to understand that
you are doing exactly opposite. I am pretty sure that other people will
confused by this as well.
> +
> #include <xen/acpi.h>
> #include <xen/console.h>
> #include <xen/cpu.h>
> --- a/xen/include/xen/elf.h
> +++ b/xen/include/xen/elf.h
> @@ -29,9 +29,14 @@
>
> #include <xen/elfstructs.h>
>
> +#ifndef ELFNOTE_CONST
> +#define ELFNOTE_CONST const
> +#endif
> +
> #define ELFNOTE_ALIGN(_n_) (((_n_)+3)&~3)
> -#define ELFNOTE_NAME(_n_) ((char*)(_n_) + sizeof(*(_n_)))
> +#define ELFNOTE_NAME(_n_) ((ELFNOTE_CONST char *)(_n_) + sizeof(*(_n_)))
> #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + ELFNOTE_ALIGN((_n_)->namesz))
> -#define ELFNOTE_NEXT(_n_) ((Elf_Note *)(ELFNOTE_DESC(_n_) +
> ELFNOTE_ALIGN((_n_)->descsz)))
> +#define ELFNOTE_NEXT(_n_) ((typeof(_n_))(ELFNOTE_DESC(_n_) + \
> + ELFNOTE_ALIGN((_n_)->descsz)))
>
> #endif /* __XEN_ELF_H__ */
--
WBR, Volodymyr
|