From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AGHT+IFPRLmN3k7B+IcLQDmyH3rfp5BUfHgOoNmEKNHFrATrQvFS+3iAQKuCrWxyU0a/vOZbjGTw+A== 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=20Poulhi=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 Content-Transfer-Encoding: 8bit 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 List-Id: 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; -- 2.42.0