Message ID | ab967347ae22d662c82962b1fdd6e6449bdd8c5e.1710145041.git.simone.ballarin@bugseng.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xen: address violation of MISRA C:2012 Directive 4.10 | expand |
On 11.03.2024 09:59, Simone Ballarin wrote: > --- a/xen/build.mk > +++ b/xen/build.mk > @@ -45,6 +45,8 @@ asm-offsets.s: arch/$(SRCARCH)/$(ARCH)/asm-offsets.c > $(CC) $(call cpp_flags,$(c_flags)) -S -g0 -o $@.new -MQ $@ $< > $(call move-if-changed,$@.new,$@) > > +ARCHDIR = $(shell echo $(SRCARCH) | tr a-z A-Z) Yet another instance? > --- a/xen/scripts/Makefile.asm-generic > +++ b/xen/scripts/Makefile.asm-generic > @@ -31,8 +31,22 @@ generated-y := $(addprefix $(obj)/, $(generated-y)) > old-headers := $(wildcard $(obj)/*.h) > unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers)) > > +define header_stub > +#ifndef ASM_GENERIC_$(3)_$(2)_H > +#define ASM_GENERIC_$(3)_$(2)_H > + > +#include <asm-generic/$(1).h> > + > +#endif /* ASM_GENERIC_$(3)_$(2)_H */ > +endef > + > +arch = $(shell echo $(SRCARCH) | tr a-z A-Z) And one more, in disguise - why not ARCHDIR here? > +header_body = $(call header_stub,$*,$(shell echo "$*" | tr a-z A-Z),$(arch)) > +export header_body This ought to be doable without involving a shell variable, I'd hope. But - this is a lot of effort just to ... > quiet_cmd_wrap = WRAP $@ > - cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@ > + cmd_wrap = echo "$$header_body" > $@ ... deal with an innocent header consisting of just a single #include. Jan
diff --git a/xen/build.mk b/xen/build.mk index 0f490ca71b..bd8b93e2ae 100644 --- a/xen/build.mk +++ b/xen/build.mk @@ -45,6 +45,8 @@ asm-offsets.s: arch/$(SRCARCH)/$(ARCH)/asm-offsets.c $(CC) $(call cpp_flags,$(c_flags)) -S -g0 -o $@.new -MQ $@ $< $(call move-if-changed,$@.new,$@) +ARCHDIR = $(shell echo $(SRCARCH) | tr a-z A-Z) + arch/$(SRCARCH)/include/asm/asm-offsets.h: asm-offsets.s @(set -e; \ echo "/*"; \ @@ -54,8 +56,8 @@ arch/$(SRCARCH)/include/asm/asm-offsets.h: asm-offsets.s echo " *"; \ echo " */"; \ echo ""; \ - echo "#ifndef __ASM_OFFSETS_H__"; \ - echo "#define __ASM_OFFSETS_H__"; \ + echo "#ifndef ASM_$(ARCHDIR)_ASM_OFFSETS_H"; \ + echo "#define ASM_$(ARCHDIR)_ASM_OFFSETS_H"; \ echo ""; \ sed -rne "/^[^#].*==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \ echo ""; \ diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic index b0d356bfa3..3b538bc7a4 100644 --- a/xen/scripts/Makefile.asm-generic +++ b/xen/scripts/Makefile.asm-generic @@ -31,8 +31,22 @@ generated-y := $(addprefix $(obj)/, $(generated-y)) old-headers := $(wildcard $(obj)/*.h) unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers)) +define header_stub +#ifndef ASM_GENERIC_$(3)_$(2)_H +#define ASM_GENERIC_$(3)_$(2)_H + +#include <asm-generic/$(1).h> + +#endif /* ASM_GENERIC_$(3)_$(2)_H */ +endef + +arch = $(shell echo $(SRCARCH) | tr a-z A-Z) + +header_body = $(call header_stub,$*,$(shell echo "$*" | tr a-z A-Z),$(arch)) +export header_body + quiet_cmd_wrap = WRAP $@ - cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@ + cmd_wrap = echo "$$header_body" > $@ quiet_cmd_remove = REMOVE $(unwanted) cmd_remove = rm -f $(unwanted)