* [PATCH v2] ELF/notes: use pointer-to-const by default in ELFNOTE_...()
@ 2026-11-18 8:24 Jan Beulich
0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2026-11-18 8:24 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Dmytro Prokopchuk
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.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Use ELFNOTE_NO_CONST as the external control identifier.
--- a/xen/common/kexec.c
+++ b/xen/common/kexec.c
@@ -6,6 +6,9 @@
* - Magnus Damm <magnus@valinux.co.jp>
*/
+/* We're producing ELF notes here. */
+#define ELFNOTE_NO_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,16 @@
#include <xen/elfstructs.h>
+#ifndef ELFNOTE_NO_CONST
+#define ELFNOTE_CONST const
+#else
+#define ELFNOTE_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__ */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-18 8:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 8:24 [PATCH v2] ELF/notes: use pointer-to-const by default in ELFNOTE_...() Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.