From patchwork Thu May 31 16:24:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Alexander Steffens X-Patchwork-Id: 575 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 4C42747F8908 for ; Thu, 31 May 2018 16:26:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on apollo X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED=0.001, DKIM_SIGNED=0.1,FREEMAIL_FROM=0.5,LONGWORDS=1.844,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,T_DKIM_INVALID=1 autolearn=no autolearn_force=no version=3.4.1 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Thu, 31 May 2018 16:26:18 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id AD3C1ADE36CB0; Thu, 31 May 2018 16:26:12 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Thu, 31 May 2018 16:26:01 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 709E12D64D; Thu, 31 May 2018 16:25:52 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=sMephu67 Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id DFC162CE22 for ; Thu, 31 May 2018 16:25:50 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Thu, 31 May 2018 16:25:50 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 24E08ADE36A2D for ; Thu, 31 May 2018 16:25:45 +0000 (UTC) Received: from mail-wr0-x233.google.com (mail-wr0-x233.google.com [IPv6:2a00:1450:400c:c0c::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Thu, 31 May 2018 16:25:39 +0000 (UTC) Received: by mail-wr0-x233.google.com with SMTP id l41-v6so33647203wre.7 for ; Thu, 31 May 2018 09:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=hN6GccyaHTm+YQhrZmNT+ncP1FoMcTcLTwUVcxVX8UQ=; b=sMephu67Jg1SdD2pAGM0e+67hjGR9pwE/6/3wsModHWOiQLkNl2/cD6zxgZyZrhWXv pdBWCAMJuF8hFKJpdLMwyhGIquFLoHGY0FAdjh7lVebEWMvPrWlLEoQUXmYUlLbPRbsn kvktIQqNknwjJfQIMteDjrnQVy28yIgzS+jyYpC25Pows0ewCPVj/JE68eFWUxt5qfLS FY6oB7zenr+AivCIvn9pTrpSgH6PVLCOrUhVVtIElRGA3L0+2lFMznD3WW6fSgA9DSwo ETbDec9FoheiJFU6bLQBtsomn8KMWudf5O+txNg01IgAplPwTSwIJa/MMcoXme81NyLE PMiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=hN6GccyaHTm+YQhrZmNT+ncP1FoMcTcLTwUVcxVX8UQ=; b=aD61f1I5HRrv5Xa1Ac9ynQvdHbhf+C1ctEf6wQ1QoY/2Jj8ABA3A0elgOEk91+iPxM TwQrthrKAGg50ighKAcO/LTBvZ44HP3xqXGRkHnFmEe53drP+J6UPvrcjLw2M3UL72Eu TnP3oDdvhWe2BwjwlTQW+ewokRzbAl4zJkpdDYaom/5iQX3UvyHBefwJjuYrvfazcSwl gMGvagF28gzUhsl7f1Yr25rIVsB6RH/7UjkgQjI8xGfyoxd9EsHhHfxPr7xvLiHAhJjK Hl02Q0Y9+y2/n841IS+YqHFiAgaTqrnzgq6hVrvm7v11+jFQH/xTpRVFjTp71SnaGvNA KQpw== X-Gm-Message-State: ALKqPwfjXYEyfNEgDJlohNcE80kN66UZGBZWdHdo3iuRvqti1bLL2A+0 t94IM6ynyEIaA6zDysz6W4C+GhH/ X-Google-Smtp-Source: ADUXVKIyNSmJjQafMhZHMeYfe1ca7emvVOQ32L4mPWd5p0cOy63i+mxdnyswKqrcvZFafv0ZSy4LpQ== X-Received: by 2002:adf:edc6:: with SMTP id v6-v6mr5385103wro.264.1527783939366; Thu, 31 May 2018 09:25:39 -0700 (PDT) Received: from philomeena.fritz.box ([2001:470:6d:88a:6bec:9309:97:97c]) by smtp.gmail.com with ESMTPSA id v196-v6sm1685341wmf.36.2018.05.31.09.25.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 09:25:38 -0700 (PDT) From: "Jan Alexander Steffens (heftig)" To: pacman-dev@archlinux.org Date: Thu, 31 May 2018 18:24:55 +0200 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Subject: [pacman-dev] [PATCH 10/10] makepkg: Don't use parameterless return X-BeenThere: pacman-dev@archlinux.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Discussion list for pacman development Errors-To: pacman-dev-bounces@archlinux.org Sender: "pacman-dev" It's especially dangerous in trap handlers since the return value of the function becomes the return value of the last command before the trap, not the last command in the current function. This applies to any function executed in a trap handler, nested functions included. In one case, install_packages failed (via return 14), which was inside a conditional that then ran exit 14, which triggered the EXIT handler, which called clean_up, which called remove_deps, which had !RMDEPS and thus returned. The return value of remove_deps became the return value of install_packages, triggering the ERR handler, which (due to another problem) was still the user function handler, which then printed a misleading error message and overrode the exit code with 4. --- scripts/makepkg.sh.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3a3f4c30..968fab0d 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -133,7 +133,7 @@ clean_up() { if (( INFAKEROOT )); then # Don't clean up when leaving fakeroot, we're not done yet. - return + return 0 fi if (( (EXIT_CODE == E_OK || EXIT_CODE == E_INSTALL_FAILED) && CLEANUP )); then @@ -313,7 +313,7 @@ resolve_deps() { } remove_deps() { - (( ! RMDEPS )) && return + (( ! RMDEPS )) && return 0 # check for packages removed during dependency install (e.g. due to conflicts) # removing all installed packages is risky in this case @@ -512,7 +512,7 @@ find_libdepends() { if (( sodepends == 0 )); then (( ${#depends[@]} )) && printf '%s\n' "${depends[@]}" - return + return 0 fi local libdeps filename soarch sofile soname soversion @@ -714,7 +714,7 @@ list_package_files() { } create_package() { - (( NOARCHIVE )) && return + (( NOARCHIVE )) && return 0 if [[ ! -d $pkgdir ]]; then error "$(gettext "Missing %s directory.")" "\$pkgdir/" @@ -779,12 +779,12 @@ create_debug_package() { # check if a debug package was requested if ! check_option "debug" "y" || ! check_option "strip" "y"; then - return + return 0 fi # check if we have any debug symbols to package if dir_is_empty "$pkgdir/usr/lib/debug"; then - return + return 0 fi unset groups depends optdepends provides conflicts replaces backup install changelog @@ -868,7 +868,7 @@ create_srcpackage() { } install_package() { - (( ! INSTALL )) && return + (( ! INSTALL )) && return 0 if (( ! SPLITPKG )); then msg "$(gettext "Installing package %s with %s...")" "$pkgname" "$PACMAN -U"