[U-Boot] [PATCH] if_changed: fix error handling

Luca Ceresoli luca at lucaceresoli.net
Mon Jun 4 14:07:53 UTC 2018


The commands in if_changed and if_changed_dep are concatenated with a
';', thus any error in any command except the last one will be
silently ignored. This is particularly relevant for the actual
payload, cmd_$(1), whose errors should not be unnoticed.

Fix by replacing the ';' with '&&'.

Signed-off-by: Luca Ceresoli <luca at lucaceresoli.net>

---

Note: I'm not aware of any situation in which this bug has any visible
effect. I noticed the problem while working on a different topic, but
later I did that job in a different way, not involving if_changed
usages. But this is a bug anyway, so let's fix it.
---
 scripts/Kbuild.include | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 2c7918ad3721..f722f75611df 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -255,16 +255,16 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
 # Execute command if command has changed or prerequisite(s) are updated.
 #
 if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \
-	@set -e;                                                             \
-	$(echo-cmd) $(cmd_$(1));                                             \
+	@set -e;                                                                 \
+	$(echo-cmd) $(cmd_$(1)) &&                                               \
 	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
 
 # Execute the command and also postprocess generated .d dependencies file.
 if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
-	@set -e;                                                             \
-	$(echo-cmd) $(cmd_$(1));                                             \
-	scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
-	rm -f $(depfile);                                                    \
+	@set -e;                                                                 \
+	$(echo-cmd) $(cmd_$(1)) &&                                               \
+	scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp &&  \
+	rm -f $(depfile) &&                                                      \
 	mv -f $(dot-target).tmp $(dot-target).cmd)
 
 # Usage: $(call if_changed_rule,foo)
-- 
2.7.4



More information about the U-Boot mailing list