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 + #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__ */
