Skip to contentSkip to conversation

kvm: fix unifdef problem

PATCH Applied Sheng Yang 2 participants 3 messages Oct 21, 2008 – Oct 22, 2008 KVM

lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

PATCH 1/1 kvm: fix unifdef problem

Reminder by Avi, unifdef need a -U parameter to deal undefined macro, other wise it can't deal with #if defined() || defined().

Also fix a historic bug on never execute unifdef...

Also discard "set -e" before unifdef, because unifdef would return 1 if it have done something to the file.

---
 kernel/Makefile |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
kernel/Makefile +6 -4
index ef18fa6..fed3bd4 100644
@@ -3,6 +3,8 @@ include config.kbuild
 
 ARCH_DIR = $(if $(filter $(ARCH),x86_64 i386),x86,$(ARCH))
 ARCH_CONFIG := $(shell echo $(ARCH_DIR) | tr '[:lower:]' '[:upper:]')
+# NONARCH_CONFIG used for unifdef, and only cover X86 and IA64 now
+NONARCH_CONFIG = $(filter-out $(ARCH_CONFIG),X86 IA64)
 
 KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR))
 
@@ -24,8 +26,8 @@ _hack = mv $1 $1.orig && \
 	    | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
 
 unifdef = mv $1 $1.orig && \
-	  unifdef -DCONFIG_$(ARCH_CONFIG) $1.orig > $1; \
-          [ $$? -le 1 ] && rm $1.orig
+	  unifdef -DCONFIG_$(ARCH_CONFIG) -UCONFIG_$(NONARCH_CONFIG) $1.orig > $1; \
+          [ $$? -le 2 ] && rm $1.orig
 
 hack = $(call _hack,$T/$(strip $1))
 
@@ -67,7 +69,7 @@ header-sync:
 	     "$(LINUX)"/arch/$(ARCH_DIR)/include/asm/./kvm*.h \
              $T/include/asm-$(ARCH_DIR)/
 
-	set -e && for i in $(find $T -name '*.h'); do \
+	for i in $$(find $T -name '*.h'); do \
 		$(call unifdef,$$i); done
 	$(call hack, include/linux/kvm.h)
 	set -e && for i in $$(find $T -type f -printf '%P '); \
@@ -81,7 +83,7 @@ source-sync:
 	     "$(LINUX)"/virt/kvm/./*.[cSh] \
 	     $T/
 
-	set -e && for i in $(find $T -name '*.c'); do \
+	for i in $$(find $T -name '*.c'); do \
 		$(call unifdef,$$i); done
 
 	for i in $(hack-files); \
Signature · 1 line
1.5.4.5
author
#1 lore raw
Quoted 7 lines · On Tuesday 21 October 2008 15:31:04 Sheng Yang wrote:

Reminder by Avi, unifdef need a -U parameter to deal undefined macro, other wise it can't deal with #if defined() || defined().

Also fix a historic bug on never execute unifdef...

Also discard "set -e" before unifdef, because unifdef would return 1 if it have done something to the file.

Hi, Christian

Can you help to check if it's affect powerpc side?

Thanks!
--
regards
Yang, Sheng

Quoted 49 lines
---
 kernel/Makefile |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
kernel/Makefile +3 -2
index ef18fa6..fed3bd4 100644
@@ -3,6 +3,8 @@ include config.kbuild
 
 ARCH_DIR = $(if $(filter $(ARCH),x86_64 i386),x86,$(ARCH))
 ARCH_CONFIG := $(shell echo $(ARCH_DIR) | tr '[:lower:]' '[:upper:]')
+# NONARCH_CONFIG used for unifdef, and only cover X86 and IA64 now
+NONARCH_CONFIG = $(filter-out $(ARCH_CONFIG),X86 IA64)
 
 KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR))
 
@@ -24,8 +26,8 @@ _hack = mv $1 $1.orig && \
 
 	    | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
 
 unifdef = mv $1 $1.orig && \
-	  unifdef -DCONFIG_$(ARCH_CONFIG) $1.orig > $1; \
-          [ $$? -le 1 ] && rm $1.orig
+	  unifdef -DCONFIG_$(ARCH_CONFIG) -UCONFIG_$(NONARCH_CONFIG) $1.orig >

$1; \ + [ $$? -le 2 ] && rm $1.orig

hack = $(call _hack,$T/$(strip $1))

kernel/Makefile +2 -2
@@ -67,7 +69,7 @@ header-sync:
 	     "$(LINUX)"/arch/$(ARCH_DIR)/include/asm/./kvm*.h \
              $T/include/asm-$(ARCH_DIR)/
 
-	set -e && for i in $(find $T -name '*.h'); do \
+	for i in $$(find $T -name '*.h'); do \
 		$(call unifdef,$$i); done
 	$(call hack, include/linux/kvm.h)
 	set -e && for i in $$(find $T -type f -printf '%P '); \
@@ -81,7 +83,7 @@ source-sync:
 	     "$(LINUX)"/virt/kvm/./*.[cSh] \
 	     $T/
 
-	set -e && for i in $(find $T -name '*.c'); do \
+	for i in $$(find $T -name '*.c'); do \
 		$(call unifdef,$$i); done
 
 	for i in $(hack-files); \
Applied
#2 lore raw
In reply to Sheng Yang
Quoted 9 lines · Sheng Yang

Reminder by Avi, unifdef need a -U parameter to deal undefined macro, other wise it can't deal with #if defined() || defined().

Also fix a historic bug on never execute unifdef...

Also discard "set -e" before unifdef, because unifdef would return 1 if it have done something to the file.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function