From patchwork Mon Oct 25 15:09:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 46628 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3E16385840B for ; Mon, 25 Oct 2021 15:18:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3E16385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635175092; bh=JXSlAz/yiC4bgeo2suJ1/QvqmSwKeRkFqc8wU/uKMA4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=uov8Ho9CjcoLKlnGo7lB2WLn4dMsmoKRI8zfIT0tBOk160l2VueXJNizq3JnGuECG CEnkkVGYB/ytFETEPXpl1ljZAxyPrvufoTMOvBOy7fWIoZreCGo0Pb0yU2vWc6a3Hd i7gXwOOgpt2KGPWLbziw/Bd7aVbk+3g8vBtEFZfQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 6C38A385801C for ; Mon, 25 Oct 2021 15:09:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C38A385801C Received: by mail-lj1-x232.google.com with SMTP id w23so8992362lje.7 for ; Mon, 25 Oct 2021 08:09:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=JXSlAz/yiC4bgeo2suJ1/QvqmSwKeRkFqc8wU/uKMA4=; b=DOHL+E9AN046Qa9Bv5wZiawl9d+63X6biHEcv4LC9b9+o6Aqik7Lf/1X+m4GXxIigv CiZ8Ebeuc1ZZ9d8Vd0X7v2hL/Qwvfv9jVTloQHQhakwaYbNWGrmCBLlJJrLwb7+53i1j uvb59WJ9HOqs2G4fb655Xnk3qxskrWESHxx1C+MuWk0Q6twlS31L2ah2f+OcK3VOy2b6 avA/ziut5qkeCgTsl1P4s3zjM85XfptlaMtI6RuJR8eudEtF4paq9tyzPUXYPCCBQjJM iPJvFCJ31HPu72YnC1gVdfb7qZl0xbp32XbwpbUl5CkCrq//s4rOEfrWyG/7r0tI/1uQ 8iYQ== X-Gm-Message-State: AOAM531y39W1L3Rrq12mYBvo3b4+ugqGnnsYeelhGZ+kkrm6dLrJUVaC nS8zHDLq5UlzpV9b+g+nqLy48hvF38W0M1Hm X-Google-Smtp-Source: ABdhPJyXlCmjEjQgHRZPCcwTw1nl9rYmeIAenpLo6ptScfjbS5iPuC6//hPspZQ4bFrhOFfTNigGsg== X-Received: by 2002:a05:651c:a09:: with SMTP id k9mr19210748ljq.442.1635174553912; Mon, 25 Oct 2021 08:09:13 -0700 (PDT) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id a16sm1667211lfu.274.2021.10.25.08.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 08:09:13 -0700 (PDT) Date: Mon, 25 Oct 2021 15:09:12 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Do not expect execv to return 0 Message-ID: <20211025150912.GA346548@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" When spawning subprocesses with fork & execv there is no need to check the result of execve, because it either succeeds and does not return or fails and returns -1. This is only a code cleanup related to the use of fork-vs-vfork in GNATprove; behaviour is unaffected, though the GNAT runtime library will be marginally smaller. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.c (__gnat_portable_spawn): Do not expect execv to return 0. (__gnat_portable_no_block_spawn): Likewise. diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -2424,8 +2424,10 @@ __gnat_portable_spawn (char *args[] ATTRIBUTE_UNUSED) if (pid == 0) { /* The child. */ - if (execv (args[0], MAYBE_TO_PTR32 (args)) != 0) - _exit (1); + execv (args[0], MAYBE_TO_PTR32 (args)); + + /* execv() returns only on error */ + _exit (1); } /* The parent. */ @@ -2822,8 +2824,10 @@ __gnat_portable_no_block_spawn (char *args[] ATTRIBUTE_UNUSED) if (pid == 0) { /* The child. */ - if (execv (args[0], MAYBE_TO_PTR32 (args)) != 0) - _exit (1); + execv (args[0], MAYBE_TO_PTR32 (args)); + + /* execv() returns only on error */ + _exit (1); } return pid;