~cypheon/ocaml-apfs

d9efb5b883d3302dd364d6f4e2f86a676d5a5280 — Johann Rudloff 1 year, 7 months ago 61b44ed
Fix FS B-tree lookups by using unsigned_compare where appropriate.
1 files changed, 4 insertions(+), 4 deletions(-)

M lib/structs/types.ml
M lib/structs/types.ml => lib/structs/types.ml +4 -4
@@ 448,8 448,8 @@ module Omap_key = struct
  [@@deriving show]

  let compare (a_oid, a_xid) (b_oid, b_xid) =
    match compare a_oid b_oid with
    | 0 -> compare a_xid b_xid
    match Int64.unsigned_compare a_oid b_oid with
    | 0 -> Int64.unsigned_compare a_xid b_xid
    | x -> x

  let of_buffer buf =


@@ 905,7 905,7 @@ module FsObject = struct
    Cstruct.LE.get_uint64 buf 8

  let compare a b = match (a,b) with
  | (DirRec dra, DirRec drb) -> (match compare dra.name_len_and_hash drb.name_len_and_hash with
  | (DirRec dra, DirRec drb) -> (match Int32.unsigned_compare dra.name_len_and_hash drb.name_len_and_hash with
    | 0 -> compare dra.name drb.name
    | x -> x
  )


@@ 940,7 940,7 @@ module FsBtree_key = struct
  let of_buffer buf = FsObject.of_buffer buf

  let compare ((aid, atyp), a) ((bid, btyp), b) =
    match compare aid bid with
    match Int64.unsigned_compare aid bid with
    | 0 -> (match compare atyp btyp with
      | 0 -> FsObject.compare a b
      | x -> x