From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzpj5-0005IN-FX for guix-patches@gnu.org; Wed, 04 Oct 2017 15:53:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzpj4-0007YH-Ju for guix-patches@gnu.org; Wed, 04 Oct 2017 15:53:03 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:40574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dzpj4-0007YB-H5 for guix-patches@gnu.org; Wed, 04 Oct 2017 15:53:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dzpj4-0004vc-AJ for guix-patches@gnu.org; Wed, 04 Oct 2017 15:53:02 -0400 Subject: [bug#28706] [PATCH 1/3] uuid: Add 'uuid=?' and use it. References: <20171004194831.4524-1-ludo@gnu.org> In-Reply-To: <20171004194831.4524-1-ludo@gnu.org> Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 4 Oct 2017 21:51:43 +0200 Message-Id: <20171004195145.4743-1-ludo@gnu.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 28706@debbugs.gnu.org * gnu/system/uuid.scm (uuid=?): New procedure. * tests/uuid.scm ("uuid=?"): New test. * gnu/build/file-systems.scm (partition-uuid-predicate) (luks-partition-uuid-predicate): Use it instead of 'bytevector=?'. --- gnu/build/file-systems.scm | 4 ++-- gnu/system/uuid.scm | 13 +++++++++++++ tests/uuid.scm | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index 32885f1d2..140bcb414 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -415,12 +415,12 @@ was READ is = to the given value." (partition-predicate read-partition-label string=?)) (define partition-uuid-predicate - (partition-predicate read-partition-uuid bytevector=?)) + (partition-predicate read-partition-uuid uuid=?)) (define luks-partition-uuid-predicate (partition-predicate (partition-field-reader read-luks-header luks-header-uuid) - bytevector=?)) + uuid=?)) (define (find-partition predicate) "Return the first partition found that matches PREDICATE, or #f if none diff --git a/gnu/system/uuid.scm b/gnu/system/uuid.scm index 6470abb8c..e422e06a6 100644 --- a/gnu/system/uuid.scm +++ b/gnu/system/uuid.scm @@ -29,6 +29,7 @@ uuid? uuid-type uuid-bytevector + uuid=? bytevector->uuid @@ -281,3 +282,15 @@ corresponding bytevector; otherwise return #f." ((_ . (? procedure? unparse)) (unparse bv)))) (((? uuid? uuid)) (uuid->string (uuid-bytevector uuid) (uuid-type uuid))))) + +(define uuid=? + ;; Return true if A is equal to B, comparing only the actual bits. + (match-lambda* + (((? bytevector? a) (? bytevector? b)) + (bytevector=? a b)) + (((? uuid? a) (? bytevector? b)) + (bytevector=? (uuid-bytevector a) b)) + (((? uuid? a) (? uuid? b)) + (bytevector=? (uuid-bytevector a) (uuid-bytevector b))) + ((a b) + (uuid=? b a)))) diff --git a/tests/uuid.scm b/tests/uuid.scm index aacce7723..68676f775 100644 --- a/tests/uuid.scm +++ b/tests/uuid.scm @@ -57,4 +57,10 @@ "1234-ABCD" (uuid->string (uuid "1234-abcd" 'fat32))) +(test-equal "uuid=?" + (and (uuid=? (uuid-bytevector (uuid "1234-abcd" 'fat32)) + (uuid "1234-abcd" 'fat32)) + (uuid=? (uuid "1234-abcd" 'fat32) + (uuid "1234-abcd" 'fat)))) + (test-end) -- 2.14.2