From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9ECA13858004 for ; Thu, 11 Jan 2024 10:46:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9ECA13858004 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9ECA13858004 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704970016; cv=none; b=eIQA9+M1ZEA3ojz2CFLjzxHVx/c8EF0K/UuPobkrRWxOxetRJMf1zVM/ipUXB5+3Yf/JkW+SNdvZl8+Sd5jkwvt/U6RQWCce3GPJqeK3mipd9aHaGpocJtQqKMVZpOUIUJwQw1YRG7JuRyFOcNDoPx4Wa2vfbxqzUCgomX/Jzdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704970016; c=relaxed/simple; bh=5Nl+7eennGKeg6jBTdfZcI5llEn54jAsY9MOj37ZImI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Q79B6otEoGG6UsTWt3dTCD06GXM7gMUYnJiWiIsF0eZbh1LVzVoWbT+8K1br5j+/NQstNYShXDm5xKZQBuXUgZa9r65SqtvxEEDpH/o0zyU7R8r2SSy3vt60uqvLg0oM/Oobbsts6nriASOKx7T8QHNeqNufQr3JgXIR4exS6NY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704970014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=72BhAUR+XmzZ1od5rlT0FyiUakiHxbPoHVK+zsXn3Fo=; b=BcuF/hKW7JGHu1U5C8+AmAwruWw11oFENQVougOd1lci9ymPq7NvdyqItq1GFJjtt5qPGX sOEF6RwjyX2aXWaQ06Pm6UCH1U93+jeQcFV/lNC8vlrXfdO13TSCQRXOfC9DaaEQfEmDUp eo/u24fPTglXu49g5IaY/7CKuwFCTaI= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-vnxAzknzMWinja9niSDT8g-1; Thu, 11 Jan 2024 05:46:53 -0500 X-MC-Unique: vnxAzknzMWinja9niSDT8g-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-5e795672280so88593187b3.3 for ; Thu, 11 Jan 2024 02:46:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704970012; x=1705574812; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=72BhAUR+XmzZ1od5rlT0FyiUakiHxbPoHVK+zsXn3Fo=; b=gcGqHsp5mR8G10EIzqoxu+4cIXDLcvwucwLjm1eWolHDr0DnJyvvNWyB/3yp7Ukdot bAbeLKu2SXiaja99BGKhiGwwqx+sPV0cMLL0uoX0EGyLmIk+9V8SWlDYds31hwImOFD+ VkZ6kO6WiFSlDXaiZqZu3UPt1MP4/Mp77ATqHEoBNKaUDk6pytfhY+4lwnmkSJ6RrLBM H90IxmRkQAmTm7a2bVL3MAXn4q0ggdmjGpiZ/3icMHLX4oDTLm14ekb9GsLv0kOwyGsw 4MjnWKJaIDVITCOchIMh1az7d/jX2ABEekDci6p7xrB0HhCSbsbwtFwhiaEfV6TGBfBY 5S8g== X-Gm-Message-State: AOJu0YxuGrlc0LzasrdaD2xoC5yw+gnmmpF5FNXShMq3KhRQo+SW+MOO gKe9mDuI+82Z8YW8udu7NKs2LQ9Qp8JT5HMZyfp7OfdBZSoZmKM+buUF/nCB2rzgeltmiPO6U3m Yt9iiCwZGhgudixbXofop3Uq0F+Pb75SpAJCdEGU= X-Received: by 2002:a81:e447:0:b0:5f8:c3a:6989 with SMTP id t7-20020a81e447000000b005f80c3a6989mr358693ywl.34.1704970012702; Thu, 11 Jan 2024 02:46:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1YtsPdRLE8hs0dsV70nrxQvPWS7h/zvT/eUMd04m7Vyi+bzCefW6rby8EM/0KMuXoxNNbUw457+mgJqRlXF0= X-Received: by 2002:a81:e447:0:b0:5f8:c3a:6989 with SMTP id t7-20020a81e447000000b005f80c3a6989mr358687ywl.34.1704970012327; Thu, 11 Jan 2024 02:46:52 -0800 (PST) MIME-Version: 1.0 References: <20240111062222.525186-1-kmatsui@gcc.gnu.org> <20240111094038.876653-1-kmatsui@gcc.gnu.org> In-Reply-To: <20240111094038.876653-1-kmatsui@gcc.gnu.org> From: Jonathan Wakely Date: Thu, 11 Jan 2024 10:46:36 +0000 Message-ID: Subject: Re: [PATCH v2 1/2] libstdc++: Fix error handling in filesystem::equivalent [PR113250] To: Ken Matsui Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: On Thu, 11 Jan 2024 at 09:43, Ken Matsui wrote: > > This patch made std::filesystem::equivalent correctly throw an exception > when either path does not exist as per [fs.op.equivalent]/4. Thanks, OK for trunk and all active branches (let me know if you need help backporting it). > > libstdc++-v3/ChangeLog: > > * src/c++17/fs_ops.cc (fs::equivalent): Use || instead of &&. > * src/filesystem/ops.cc (fs::equivalent): Likewise. > * testsuite/27_io/filesystem/operations/equivalent.cc: Handle > error codes. > * testsuite/experimental/filesystem/operations/equivalent.cc: > Likewise. > > Signed-off-by: Ken Matsui > --- > libstdc++-v3/src/c++17/fs_ops.cc | 2 +- > libstdc++-v3/src/filesystem/ops.cc | 2 +- > .../testsuite/27_io/filesystem/operations/equivalent.cc | 4 ++-- > .../experimental/filesystem/operations/equivalent.cc | 4 ++-- > 4 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libstdc++-v3/src/c++17/fs_ops.cc b/libstdc++-v3/src/c++17/fs_ops.cc > index e0b308a37ea..61df19753ef 100644 > --- a/libstdc++-v3/src/c++17/fs_ops.cc > +++ b/libstdc++-v3/src/c++17/fs_ops.cc > @@ -897,7 +897,7 @@ fs::equivalent(const path& p1, const path& p2, error_code& ec) noexcept > return st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino; > #endif > } > - else if (!exists(s1) && !exists(s2)) > + else if (!exists(s1) || !exists(s2)) > ec = std::make_error_code(std::errc::no_such_file_or_directory); > else if (err) > ec.assign(err, std::generic_category()); > diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc > index eccdae3d910..4d23a804da0 100644 > --- a/libstdc++-v3/src/filesystem/ops.cc > +++ b/libstdc++-v3/src/filesystem/ops.cc > @@ -765,7 +765,7 @@ fs::equivalent(const path& p1, const path& p2, error_code& ec) noexcept > return false; > return st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino; > } > - else if (!exists(s1) && !exists(s2)) > + else if (!exists(s1) || !exists(s2)) > ec = std::make_error_code(std::errc::no_such_file_or_directory); > else if (err) > ec.assign(err, std::generic_category()); > diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/equivalent.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/equivalent.cc > index 78f6e368204..68f32366d65 100644 > --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/equivalent.cc > +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/equivalent.cc > @@ -34,13 +34,13 @@ test01() > bool result; > > result = equivalent(p1, p2, ec); > - VERIFY( ec ); > + VERIFY( ec == std::errc::no_such_file_or_directory ); > VERIFY( !result ); > > __gnu_test::scoped_file f1(p1); > ec = bad_ec; > result = equivalent(p1, p2, ec); > - VERIFY( !ec ); > + VERIFY( ec == std::errc::no_such_file_or_directory ); > VERIFY( !result ); > > __gnu_test::scoped_file f2(p2); > diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/equivalent.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/equivalent.cc > index 929a6ca8609..5bc477a31cd 100644 > --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/equivalent.cc > +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/equivalent.cc > @@ -35,13 +35,13 @@ test01() > bool result; > > result = equivalent(p1, p2, ec); > - VERIFY( ec ); > + VERIFY( ec == std::errc::no_such_file_or_directory ); > VERIFY( !result ); > const auto bad_ec = ec; > > __gnu_test::scoped_file f1(p1); > result = equivalent(p1, p2, ec); > - VERIFY( !ec ); > + VERIFY( ec == std::errc::no_such_file_or_directory ); > VERIFY( !result ); > > __gnu_test::scoped_file f2(p2); > -- > 2.43.0 >