[U-Boot] [PATCH] if_changed: fix error handling
Chris Packham
judge.packham at gmail.com
Wed Jun 6 03:23:20 UTC 2018
Hi,
On Tue, Jun 5, 2018 at 2:08 AM Luca Ceresoli <luca at lucaceresoli.net> wrote:
>
> 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)
The 'set -e' should cause the sub-shell to exit immediately if any of
the commands fail, regardless of the ';' vs '&&'.
Assuming I'm wrong above, this patch should probably go to the kbuild
mailing list http://vger.kernel.org/vger-lists.html#linux-kbuild
More information about the U-Boot
mailing list