Skip to content

Commit

Permalink
Set mode flag to 0 when not using O_CREATE in Unix.openfile
Browse files Browse the repository at this point in the history
The mode was 0644 but in OCaml that's decimal and not octal, the
correct integer literal would have been 0o644. However, as the calls
don't use O_CREAT, it doesn't matter. Setting the parameter to 0 is
cleaner.
  • Loading branch information
MisterDA committed Sep 14, 2021
1 parent 92298e6 commit fd02759
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions unix/tar_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module Archive = struct
| None -> Lwt.return_unit
| Some hdr ->
let filename = dest hdr.Tar.Header.file_name in
Lwt_unix.openfile filename [Unix.O_WRONLY] 0644 >>= fun ofd ->
Lwt_unix.openfile filename [Unix.O_WRONLY] 0 >>= fun ofd ->
copy_n ifd ofd hdr.Tar.Header.file_size >>= fun () ->
Reader.skip ifd (Tar.Header.compute_zero_padding_length hdr) >>= fun () ->
loop () in
Expand All @@ -143,7 +143,7 @@ module Archive = struct
header_of_file filename >>= fun hdr ->

write_block hdr (fun ofd ->
Lwt_unix.openfile filename [Unix.O_RDONLY] 0644 >>= fun ifd ->
Lwt_unix.openfile filename [Unix.O_RDONLY] 0 >>= fun ifd ->
copy_n ifd ofd hdr.Tar.Header.file_size
) ofd
end in
Expand Down
4 changes: 2 additions & 2 deletions unix/tar_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module Archive = struct
let extract dest ifd =
let dest hdr =
let filename = dest hdr.Tar.Header.file_name in
Unix.openfile filename [Unix.O_WRONLY] 0644
Unix.openfile filename [Unix.O_WRONLY] 0
in
extract_gen dest ifd

Expand All @@ -100,7 +100,7 @@ module Archive = struct
else
let hdr = header_of_file filename in
Some (hdr, (fun ofd ->
let ifd = Unix.openfile filename [Unix.O_RDONLY] 0644 in
let ifd = Unix.openfile filename [Unix.O_RDONLY] 0 in
copy_n ifd ofd hdr.Tar.Header.file_size))
in
List.filter_map f files
Expand Down

0 comments on commit fd02759

Please sign in to comment.