From patchwork Tue Oct 10 12:14:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 150725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp153703vqb; Tue, 10 Oct 2023 05:19:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNHc4zCURsBsn0RqF6YrIYISqA11IXsWfbX5/G6bh8XdLrG8dka+ZTV2AGebqOHjFh2PNN X-Received: by 2002:a17:906:20e:b0:9ad:7e21:5a6d with SMTP id 14-20020a170906020e00b009ad7e215a6dmr15701797ejd.33.1696940356563; Tue, 10 Oct 2023 05:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696940356; cv=none; d=google.com; s=arc-20160816; b=ohr7ASwuwPMne1iSqT5e3ehJWJxykZxB5521qeof1lPcXhf8/JxUpDGdNXoE9VfAE/ eXSbqj05C8uaz500gFztE8byvtetCUdP1ZhBBZHRwoojsPxPOrnb08KerNIGPYxcY/9h QP/zSBorBaCQTvJ73pArK0Qv8FExfUAH8HPaRct5B6uAaWq4kHUqW/7gdN9G36Xt9fUT Q6XGbtqrtQ4Ly5UlG8rlZkTDOXxLh/xpiXGRRtDu3ui+hN9YNsmtWlZx/iQcIeaZHqva BlWTl3cuLlZSAz0NhlkY3b+yOP7F6J/4jVVAAWym9FhJD44huJacWIBvZEOBAvC7fyCK LZ9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=4KhY0NQ66Ot2PQxmsAHBFu/gk86yqfLef2pHq9wn3Ek=; fh=/LGSvS9fKr8xUSOarN/hPHAOWzvFwgUy+6Y4FjnH2j4=; b=mSCDZtCfaaY9bVnoNDmtduC5NzMDm+wwToqsl9GrfiJknsroi1D/Uj+If01kKhCmyK zqKgUqB9DAOLrKGj1AloPlOcuAaAxWzFc1dzs3dtb+qZCDvN8lSlGdzac0umbi6LxNNk knfu6HiFDXcZmktMwzuqH2sysxGVQ0jIzGJSAUehxNCNOOXhl3QwnkRaPCGCGokAiYsd uNcp0RdGewtEryvY5QuRY9DvGS1uRpdWh3qOkEsg/eW4j0wKB25FdpTJQPKcJgwKQHlh y4lph+1LqDwv1fFXzTb727ERwPEFhpHchn+U2/21mLA6LldJCz0C3zdDNtvOdBhUmVap jh3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=emDvMlVE; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id lv11-20020a170906bc8b00b009a1ac68daa3si5633531ejb.160.2023.10.10.05.19.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 05:19:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=emDvMlVE; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30D6D3889E0F for ; Tue, 10 Oct 2023 12:15:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 90911386188C for ; Tue, 10 Oct 2023 12:15:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90911386188C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-32167a4adaaso5083426f8f.1 for ; Tue, 10 Oct 2023 05:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696940100; x=1697544900; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4KhY0NQ66Ot2PQxmsAHBFu/gk86yqfLef2pHq9wn3Ek=; b=emDvMlVEn/sM2KSTQiLmmhBuJr4dem5njGLrF7VZskFSVnNZeGLqQ5mXuYl1wXJR8C ACmdEuJEKiTWigKRgkQl0BSOk6qjwiBR4uF9k9WyGHHhyRfkRE/6gVvH4vi5f78Vtz2p 4lsoG4rNkz22Ng82V4ZFGJuTFNi9OVrDPGKeIvRqgRI1wX7Pi89C6VanOdsommJPJfVS zs+kro9Vow54DHUz8TuiHf2jTWiW0K6t5GRMZI8U0E6XJuWtKbxKJZh+P4R1SgG+4/1F 2xr3+F8Hw4XyPWvC5QeVO8Go2Q6SmFbjHDTPpBp8ELzTnAHPnpLpCdM3luB2oe8q4iic zWsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696940100; x=1697544900; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4KhY0NQ66Ot2PQxmsAHBFu/gk86yqfLef2pHq9wn3Ek=; b=aGLq0h+u0NDECmyqVC88DXdkDlTYk9lrxSO+1BMO+pbVXxuxw1qX5+mz8Wwn0j87nb JnX8WvFpzsRy2DcXNrLhDL9iSx7kjNHtf2KSptwXqcM7vQiGPUNA5/p8PntKX0gykkI6 ibZDTIYEWZQEUKpODTFZe/0DMSmLdOa5UAd5OeDqNrzH8TRlJhAHdpVrNAkr9J9+LKDQ dCZ+/+R8F4jnm7/jwq4vbdoatw3BS6uaRnfsPXD/ith/Ca7TaKQnmpUIsS0zZkvcsGOE waDsIh+6an16BXmot2s0VmHsXpKrnF132+WVvwuqa5i12hAhsjpfPLfYJHTdTobfxUL1 lOWQ== X-Gm-Message-State: AOJu0Yye4lJa+JdRq1KAcPb+dUxHCFT5BXuvdf4ntvYynhBff54ZrPtd /xHsWoHQbHrmjFD83yq8uIw0a3mB/H1LkaA+gf+Lpg== X-Received: by 2002:adf:b34a:0:b0:329:6b9d:d34b with SMTP id k10-20020adfb34a000000b003296b9dd34bmr9036065wrd.61.1696940098495; Tue, 10 Oct 2023 05:14:58 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id c12-20020a05600c0acc00b00402f713c56esm14013227wmr.2.2023.10.10.05.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 05:14:58 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED] ada: Tweak internal subprogram in Ada.Directories Date: Tue, 10 Oct 2023 14:14:57 +0200 Message-ID: <20231010121457.3888606-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779370931093937835 X-GMAIL-MSGID: 1779370931093937835 From: Ronan Desplanques The purpose of this patch is to work around false-positive warnings emitted by GNAT SAS (also known as CodePeer). It does not change the behavior of the modified subprogram. gcc/ada/ * libgnat/a-direct.adb (Start_Search_Internal): Tweak subprogram body. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/a-direct.adb | 46 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/gcc/ada/libgnat/a-direct.adb b/gcc/ada/libgnat/a-direct.adb index f7a1d5dfd6d..594971c6021 100644 --- a/gcc/ada/libgnat/a-direct.adb +++ b/gcc/ada/libgnat/a-direct.adb @@ -1379,13 +1379,21 @@ package body Ada.Directories is Compose (Directory, File_Name) & ASCII.NUL; Path : String renames Path_C (Path_C'First .. Path_C'Last - 1); - Found : Boolean := False; Attr : aliased File_Attributes; Exists : Integer; Error : Integer; - Kind : File_Kind; - Size : File_Size; + type Result (Found : Boolean := False) is record + case Found is + when True => + Kind : File_Kind; + Size : File_Size; + when False => + null; + end case; + end record; + + Res : Result := (Found => False); begin -- Get the file attributes for the directory item @@ -1416,32 +1424,28 @@ package body Ada.Directories is if Is_Regular_File_Attr (Path_C'Address, Attr'Access) = 1 then if Filter (Ordinary_File) then - Found := True; - Kind := Ordinary_File; - Size := - File_Size - (File_Length_Attr - (-1, Path_C'Address, Attr'Access)); + Res := (Found => True, + Kind => Ordinary_File, + Size => File_Size + (File_Length_Attr + (-1, Path_C'Address, Attr'Access))); end if; elsif Is_Directory_Attr (Path_C'Address, Attr'Access) = 1 then if Filter (File_Kind'First) then - Found := True; - Kind := File_Kind'First; - -- File_Kind'First is used instead of Directory due - -- to a name overload issue with the procedure - -- parameter Directory. - Size := 0; + Res := (Found => True, + Kind => File_Kind'First, + Size => 0); end if; elsif Filter (Special_File) then - Found := True; - Kind := Special_File; - Size := 0; + Res := (Found => True, + Kind => Special_File, + Size => 0); end if; - if Found then + if Res.Found then Search.State.Dir_Contents.Append (Directory_Entry_Type' (Valid => True, @@ -1449,9 +1453,9 @@ package body Ada.Directories is To_Unbounded_String (File_Name), Full_Name => To_Unbounded_String (Path), Attr_Error_Code => 0, - Kind => Kind, + Kind => Res.Kind, Modification_Time => Modification_Time (Path), - Size => Size)); + Size => Res.Size)); end if; end if; end;