Skip to content

Commit 82b3436

Browse files
committed
conditionally import crate::off_t in fcntl
The import of off_t is not always needed, leading to unused import warnings. Conditionally importing it makes the warnings go away.
1 parent 138a078 commit 82b3436

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/fcntl.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::errno::Errno;
2-
use crate::off_t;
32
use libc::{self, c_char, c_int, c_uint, size_t, ssize_t};
43
use std::ffi::OsString;
54
#[cfg(not(target_os = "redox"))]
@@ -12,6 +11,17 @@ use crate::{sys::stat::Mode, NixPath, Result};
1211
#[cfg(any(target_os = "android", target_os = "linux"))]
1312
use std::ptr; // For splice and copy_file_range
1413

14+
#[cfg(any(
15+
target_os = "linux",
16+
target_os = "android",
17+
target_os = "dragonfly",
18+
target_os = "emscripten",
19+
target_os = "fuchsia",
20+
target_os = "wasi",
21+
target_os = "freebsd"
22+
))]
23+
use crate::off_t;
24+
1525
#[cfg(any(
1626
target_os = "linux",
1727
target_os = "android",
@@ -758,7 +768,7 @@ pub fn fallocate(
758768
/// the file offset, and the second is the length of the region.
759769
#[cfg(any(target_os = "freebsd"))]
760770
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
761-
pub struct SpacectlRange(pub libc::off_t, pub libc::off_t);
771+
pub struct SpacectlRange(pub off_t, pub off_t);
762772

763773
#[cfg(any(target_os = "freebsd"))]
764774
impl SpacectlRange {
@@ -768,12 +778,12 @@ impl SpacectlRange {
768778
}
769779

770780
#[inline]
771-
pub fn len(&self) -> libc::off_t {
781+
pub fn len(&self) -> off_t {
772782
self.1
773783
}
774784

775785
#[inline]
776-
pub fn offset(&self) -> libc::off_t {
786+
pub fn offset(&self) -> off_t {
777787
self.0
778788
}
779789
}
@@ -868,8 +878,8 @@ pub fn fspacectl(fd: RawFd, range: SpacectlRange) -> Result<SpacectlRange> {
868878
#[cfg(target_os = "freebsd")]
869879
pub fn fspacectl_all(
870880
fd: RawFd,
871-
offset: libc::off_t,
872-
len: libc::off_t,
881+
offset: off_t,
882+
len: off_t,
873883
) -> Result<()> {
874884
let mut rqsr = libc::spacectl_range {
875885
r_offset: offset,

0 commit comments

Comments
 (0)