Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
radicle: use rlim_t when working with limits
Merged did:key:z6Mks3J8...KiVs opened 1 year ago

rlimit values have different types on Linux and FreeBSD, as well as 64-bit and 32-bit platforms, so stick to the type rlim_t provided by the libc crate.

1 file changed +2 -5 87cb7bf5 41c33901
modified radicle/src/io.rs
@@ -1,12 +1,9 @@
use std::fmt;
use std::io;

-
use libc::{getrlimit, rlimit, setrlimit, RLIMIT_NOFILE};
+
use libc::{getrlimit, rlim_t, rlimit, setrlimit, RLIMIT_NOFILE};

-
#[cfg(not(target_os = "freebsd"))]
-
type Int = u64;
-
#[cfg(target_os = "freebsd")]
-
type Int = i64;
+
type Int = rlim_t;

/// Sets the open file limit to the given value, or the maximum allowed value.
pub fn set_file_limit<N>(n: N) -> io::Result<Int>