From patchwork Tue Feb 12 03:44:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 158064 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3365051jaa; Mon, 11 Feb 2019 19:46:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IZrSw04lSG1SjkcTSWrFAFXmH2gADq9TwWNndxce08ivs32FBXULvxiT41OvaNRRBkpQOBj X-Received: by 2002:a63:ea42:: with SMTP id l2mr1620181pgk.213.1549943187407; Mon, 11 Feb 2019 19:46:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549943187; cv=none; d=google.com; s=arc-20160816; b=Qn0P4mRVuaSbRClNRFqowJ4Wv8gwvWy5jj6BgCdB3pSy/+ESPp6C41i9j6wkJ/zVWq Fh8YdjsfquRJ3DlBjFPOvg12z5HHhtFHWv961CtCwQjxLQWwyvLF3yP+uKce7RlrcQk/ pOensI/k+UMSpHGumZurz/slCQMWNbuwxu95wG83gKCM/f3sO9hUu5JS1HTxwuhH1RKp cX3wdrxe8E2s+dZQEKsZPPZaOhjK4JFoV/vVLutQAwTgxFiprjo3EpiO04HmuP2zPIn6 n+/TAfdBy2+kb7X+FjBUw1D0AgwT1QdGHDIaxEP8tjXWGk4P1A1fU7z6GpFG1zFwMSOO ubYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=qBZd1c9KzcEe6uaLQVppkNCLI29LIZhWS8mr/U0FrbI=; b=Vd0748XiYMpNjFAKd8iamj7wtNQzHTpcqIm7dr1RQBdzAmCsQzyCt4cwAp0KrNDUXK clK+723Cfa0tU+5qgRdVGR5Lwt/ntQ9vCHBiPnhK41G8Bvp30R+K3EqpQwgnlFUlyhrn +NNIjtSoHfz/VP4+o9sTLzwGk206r3nUWl70yx/onEvwhCn77Sl1snI4iBWHWbHsqP3D KUbYFjg7BvodHfGPGvk0xpUmN8DARkp89Rl7A7s1aHgOZ2cylqgentSZ3yTEbzhJoiyA WA+QKQZpPgPC6TgIQCZZubQlTNlP579F4YCU3unANgEaU27ERvZrV4BDS2xyzJ2wDrAP kTjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=yqlGqFFc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u63si4227480pfi.196.2019.02.11.19.46.27; Mon, 11 Feb 2019 19:46:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=yqlGqFFc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727391AbfBLDqZ (ORCPT + 31 others); Mon, 11 Feb 2019 22:46:25 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:53954 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726699AbfBLDqY (ORCPT ); Mon, 11 Feb 2019 22:46:24 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id x1C3j8aH007458; Tue, 12 Feb 2019 12:45:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x1C3j8aH007458 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1549943109; bh=qBZd1c9KzcEe6uaLQVppkNCLI29LIZhWS8mr/U0FrbI=; h=From:To:Cc:Subject:Date:From; b=yqlGqFFcSlVvnI1KWllZ44LJtZUJtfaw+/CSlz8RvVrIRoQYga3eucc+oz829AF26 f5Q18XuL4+m4TtbIPGM6fN9JraQ1j61JtI0uoGfPKbBSkgjDZ58FuJaDkfgb1SP/ag ctr+Oy+9mKsUueoz1bPBiKYzJ63UuH0ts76OEeJZJ0cra0EZKiScf+BZ6s17ORmJPz FaSpoxipfjImLYC94coZhKrvZlZjM6u6ZxdWnuOnDyKe8JDV/D1xHKZROSFgjDKD2Y md37GqkWzwIpxh5VYEzhOKCaV56bPEsqWebN6u3DkSrTLOWjTef1a5O5GwmR0YPgc7 +E0F+pTYe+eNw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Ard Biesheuvel , linux-kernel@vger.kernel.org Cc: Ingo Molnar , Masahiro Yamada , linux-efi@vger.kernel.org, Kees Cook , Alistair Strachan , Laura Abbott , Will Deacon , Ingo Molnar , Nathan Chancellor Subject: [PATCH] efi/libstub: refactor cmd_stubcopy Date: Tue, 12 Feb 2019 12:44:55 +0900 Message-Id: <1549943095-10956-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It took me a while to understand what is going on in the nested if-blocks. Simplify it by removing unneeded code. - if_changed automatically adds 'set -e', so any failure in the series of commands makes it immediately fail as a whole. So, the outer if block is entirely redundant. - Since commit 9c2af1c7377a ("kbuild: add .DELETE_ON_ERROR special target"), GNU Make automatically deletes the target on any failure in its recipe. The explicit 'rm -f $@' is redundant. - surrounding commands with ( ) will spawn a subshell to execute them in it, but it is rarely useful to do so. Signed-off-by: Masahiro Yamada --- drivers/firmware/efi/libstub/Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.7.4 Acked-by: Ard Biesheuvel diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index d984509..7788e8a 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -86,12 +86,13 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE # this time, use objcopy and leave all sections in place. # quiet_cmd_stubcopy = STUBCPY $@ - cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \ - then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \ - then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \ - rm -f $@; /bin/false); \ - else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi \ - else /bin/false; fi + cmd_stubcopy = \ + $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \ + if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \ + echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \ + /bin/false; \ + fi; \ + $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@ # # ARM discards the .data section because it disallows r/w data in the