refactor: resolved cross-platform build warnings and add windows-sys features
- Add conditional attributes to silence dead-code warnings on platform-specific code and fields. - Update target dependencies in pi-walker/Cargo.toml with explicit windows-sys feature sets. - Simplify time cast expressions in linux_reflink and rcopy modules.
This commit is contained in:
@@ -248,14 +248,8 @@ mod imp {
|
||||
|
||||
fn set_times_nofollow(path: &Path, meta: &fs::Metadata) -> std::io::Result<()> {
|
||||
let times = [
|
||||
libc::timespec {
|
||||
tv_sec: meta.atime() as libc::time_t,
|
||||
tv_nsec: meta.atime_nsec() as libc::c_long,
|
||||
},
|
||||
libc::timespec {
|
||||
tv_sec: meta.mtime() as libc::time_t,
|
||||
tv_nsec: meta.mtime_nsec() as libc::c_long,
|
||||
},
|
||||
libc::timespec { tv_sec: meta.atime() as _, tv_nsec: meta.atime_nsec() as libc::c_long },
|
||||
libc::timespec { tv_sec: meta.mtime() as _, tv_nsec: meta.mtime_nsec() as libc::c_long },
|
||||
];
|
||||
let c_path = CString::new(path.as_os_str().as_bytes())?;
|
||||
// SAFETY: `c_path` and `times` live until the syscall returns; the
|
||||
|
||||
@@ -413,11 +413,10 @@ fn filetime_set(path: &Path, mtime: std::time::SystemTime) -> std::io::Result<()
|
||||
let dur = mtime
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map_err(std::io::Error::other)?;
|
||||
let times =
|
||||
[libc::timespec { tv_sec: dur.as_secs() as libc::time_t, tv_nsec: 0 }, libc::timespec {
|
||||
tv_sec: dur.as_secs() as libc::time_t,
|
||||
tv_nsec: dur.subsec_nanos() as libc::c_long,
|
||||
}];
|
||||
let times = [libc::timespec { tv_sec: dur.as_secs() as _, tv_nsec: 0 }, libc::timespec {
|
||||
tv_sec: dur.as_secs() as _,
|
||||
tv_nsec: dur.subsec_nanos() as libc::c_long,
|
||||
}];
|
||||
let c_path = std::ffi::CString::new(path.as_os_str().as_bytes())?;
|
||||
// SAFETY: `c_path` and `times` outlive the syscall; the kernel does
|
||||
// not retain the pointers.
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
//! thread-local context isolated across concurrent pipeline stages and avoids
|
||||
//! blocking the async runtime on synchronous utility I/O.
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::ffi::OsStr;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ffi::{OsStr, OsString},
|
||||
ffi::OsString,
|
||||
io::{self, Read, Write},
|
||||
panic::catch_unwind,
|
||||
sync::{
|
||||
@@ -106,6 +108,7 @@ async fn run_uutil<SE: ShellExtensions>(
|
||||
|
||||
// brush passes the command name as the first `CommandArg`, which is exactly
|
||||
// the argv[0] uutils' argument parsing expects.
|
||||
#[cfg_attr(not(unix), allow(unused_mut))]
|
||||
let mut argv: Vec<OsString> = args
|
||||
.iter()
|
||||
.map(|arg| OsString::from(arg.to_string()))
|
||||
|
||||
@@ -511,12 +511,14 @@ struct SizeFilter {
|
||||
bytes: u64,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
#[derive(Clone, Copy)]
|
||||
enum OwnerSide {
|
||||
Include(u32),
|
||||
Exclude(u32),
|
||||
}
|
||||
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
#[derive(Clone, Copy)]
|
||||
struct OwnerMatcher {
|
||||
user: Option<OwnerSide>,
|
||||
@@ -1183,6 +1185,7 @@ fn matches_owner_filters(filters: &[OwnerMatcher], _metadata: Option<&Metadata>)
|
||||
filters.is_empty()
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
const fn owner_side_matches(side: OwnerSide, actual: u32) -> bool {
|
||||
match side {
|
||||
OwnerSide::Include(expected) => actual == expected,
|
||||
|
||||
@@ -29,6 +29,7 @@ struct Ctx {
|
||||
stdin: Box<dyn Read + Send>,
|
||||
/// Raw fd backing `stdin` when it is a real OS file/pipe, used for
|
||||
/// cancellable readiness polling on unix. `None` for non-fd readers.
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
stdin_fd: Option<i32>,
|
||||
/// Whether stdin is a shell pipe/stream that should be searched implicitly.
|
||||
stdin_is_search_input: bool,
|
||||
|
||||
@@ -20,4 +20,10 @@ rayon.workspace = true
|
||||
libc.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { workspace = true, features = ["Wdk_Storage_FileSystem"] }
|
||||
windows-sys = { workspace = true, features = [
|
||||
"Wdk_Storage_FileSystem",
|
||||
"Win32_Foundation",
|
||||
"Win32_Security",
|
||||
"Win32_Storage_FileSystem",
|
||||
"Win32_System_IO",
|
||||
] }
|
||||
|
||||
@@ -12,6 +12,7 @@ use nix::unistd::Group;
|
||||
use super::{ComparableValue, Matcher, MatcherIO, WalkEntry};
|
||||
|
||||
pub struct GroupMatcher {
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
gid: ComparableValue,
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use nix::unistd::User;
|
||||
use super::{ComparableValue, Matcher, MatcherIO, WalkEntry};
|
||||
|
||||
pub struct UserMatcher {
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
uid: ComparableValue,
|
||||
}
|
||||
|
||||
|
||||
Vendored
+6
@@ -146,8 +146,10 @@ for details about the options it supports.";
|
||||
#[error("{directive}: invalid directive")]
|
||||
InvalidDirective { directive: String },
|
||||
#[error("cannot read table of mounted file systems: {error}")]
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
CannotReadFilesystem { error: String },
|
||||
#[error("using '-' to denote standard input does not work in file system mode")]
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
StdinFilesystemMode,
|
||||
#[error("cannot read file system information for {file}: {error}")]
|
||||
CannotReadFilesystemInfo { file: String, error: String },
|
||||
@@ -275,6 +277,7 @@ for details about the options it supports.";
|
||||
#[derive(Debug)]
|
||||
pub enum OutputType<'a> {
|
||||
Str(String),
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
OsStr(&'a OsString),
|
||||
Integer(i64),
|
||||
Unsigned(u64),
|
||||
@@ -413,9 +416,12 @@ for details about the options it supports.";
|
||||
show_fs: bool,
|
||||
from_user: bool,
|
||||
files: Vec<OsString>,
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
mount_list: OnceCell<Option<Vec<OsString>>>,
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
mount_list_needed: bool,
|
||||
default_tokens: Vec<Token>,
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
default_dev_tokens: Vec<Token>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1044,7 +1044,6 @@ export interface RegisteredCommand {
|
||||
// ============================================================================
|
||||
|
||||
/** Handler function type for events */
|
||||
// biome-ignore lint/suspicious/noConfusingVoidType: void allows bare return statements
|
||||
export type ExtensionHandler<E, R = undefined> = (event: E, ctx: ExtensionContext) => Promise<R | void> | R | void;
|
||||
|
||||
/** Service tiers accepted by each provider family. */
|
||||
|
||||
@@ -444,7 +444,6 @@ export type {
|
||||
* Handler function type for each event.
|
||||
* Handlers can return R, undefined, or void (bare return statements).
|
||||
*/
|
||||
// biome-ignore lint/suspicious/noConfusingVoidType: void allows bare return statements in handlers
|
||||
export type HookHandler<E, R = undefined> = (event: E, ctx: HookContext) => Promise<R | void> | R | void;
|
||||
|
||||
export interface HookMessageRenderOptions {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
### Fixed
|
||||
|
||||
- napi binding build failures now surface the exit code and the tail of stdout/stderr instead of a bare "napi build failed" message ([#6799](https://github.com/can1357/oh-my-pi/pull/6799)).
|
||||
- Silenced cross-platform Rust build warnings: dead-code on unix-only fields/helpers in `pi-uutils-ctx`, `pi-shell` (fd owner filters, coreutils argv), and vendored `uu-find`/`uu-stat` when compiling for Windows, and deprecated `libc::time_t` casts in `pi-iso` on musl. `pi-walker` now declares the `windows-sys` features it uses (`Win32_Foundation`, `Win32_Security`, `Win32_Storage_FileSystem`, `Win32_System_IO`) instead of relying on workspace-wide feature unification.
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ const VENDORED_FORK_EXCLUDES = [
|
||||
const TASK_COMMANDS = {
|
||||
"check:rs": [
|
||||
["cargo", "fmt", "--all", "--", "--check"],
|
||||
["cargo", "clippy", "--workspace", ...VENDORED_FORK_EXCLUDES, "--", "-D", "warnings"],
|
||||
["cargo", "clippy", "--workspace", ...VENDORED_FORK_EXCLUDES, "--no-deps", "--", "-D", "warnings"],
|
||||
],
|
||||
"fix:rs": [
|
||||
["cargo", "fmt", "--all"],
|
||||
@@ -43,7 +43,7 @@ const TASK_COMMANDS = {
|
||||
],
|
||||
],
|
||||
"fmt:rs": [["cargo", "fmt", "--all"]],
|
||||
"lint:rs": [["cargo", "clippy", "--workspace", ...VENDORED_FORK_EXCLUDES, "--", "-D", "warnings"]],
|
||||
"lint:rs": [["cargo", "clippy", "--workspace", ...VENDORED_FORK_EXCLUDES, "--no-deps", "--", "-D", "warnings"]],
|
||||
"test:rs": [
|
||||
[
|
||||
"cargo",
|
||||
|
||||
Reference in New Issue
Block a user