Hi Jan,

Jan Beulich <[email protected]> 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 <[email protected]>
>
> --- a/xen/common/kexec.c
> +++ b/xen/common/kexec.c
> @@ -6,6 +6,9 @@
>   * - Magnus Damm <[email protected]>
>   */
>  
> +/* 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

Reply via email to