clippy: clear the workspace errors and apply the machine fixes

- Mark the raw-pointer interop entry points unsafe with # Safety docs
  (oak-core upload/download/frame-from-pixels, oak-audio convert) and
  satisfy the existing callers (tests).
- mut_from_ref: allow with the ABI contract documented (the handle
  get_mut helpers in oak-timeline/oak-render/oak-task take the shared
  reference the C ABI passes; exclusivity is the caller's unsafe
  contract).
- Fix the eq_op in the white-balance normalization (green / green).
- Apply cargo clippy --fix across the workspace (redundant closures and
  field names, field reassignment, items after test modules, ...).
- Revert the replace_box fix in image_effect's clip_define: a
  redefinition must allocate a new box, otherwise the old clip handle
  stays valid and the HS-map replace contract (clip != clip2) breaks.
- 283 warnings remain; they are all non-machine-applicable
  (chunks_exact -> as_chunks needs a manual iter_mut, too_many_arguments,
  complex types, missing Safety docs, ...) and are tracked as the
  follow-up.
This commit is contained in:
2026-09-15 19:29:32 +08:00
parent 7e87ec135e
commit ee7ea18d94
146 changed files with 5235 additions and 4046 deletions
+6 -6
View File
@@ -144,7 +144,7 @@ fn uuid_text_to_bytes(uuid: &str) -> [u8; 16] {
break;
}
let d = c.to_digit(16).unwrap_or(0) as u8;
if nibble % 2 == 0 {
if nibble.is_multiple_of(2) {
bytes[nibble / 2] = d << 4;
} else {
bytes[nibble / 2] |= d;
@@ -286,7 +286,7 @@ impl PlaybackCache {
pub fn set_uuid(&mut self, uuid: &str) {
self.uuid = uuid.to_string();
let dir = self.disk_dir.clone();
let _ = self.load_state(&std::path::Path::new(&dir));
let _ = self.load_state(std::path::Path::new(&dir));
}
/// Set the frame timebase (frame-hash flavors; C++ `set_timebase`).
@@ -319,7 +319,7 @@ impl PlaybackCache {
self.passthroughs.retain(|(r, _)| !overlaps(*r, range));
if self.saving_enabled {
let dir = self.disk_dir.clone();
let _ = self.save_state(&std::path::Path::new(&dir));
let _ = self.save_state(std::path::Path::new(&dir));
}
}
@@ -328,7 +328,7 @@ impl PlaybackCache {
self.validated.insert(range);
if self.saving_enabled {
let dir = self.disk_dir.clone();
let _ = self.save_state(&std::path::Path::new(&dir));
let _ = self.save_state(std::path::Path::new(&dir));
}
}
@@ -401,7 +401,7 @@ impl PlaybackCache {
}
if self.saving_enabled {
let dir = self.disk_dir.clone();
let _ = self.save_state(&std::path::Path::new(&dir));
let _ = self.save_state(std::path::Path::new(&dir));
}
}
@@ -421,7 +421,7 @@ impl PlaybackCache {
}
if self.saving_enabled {
let dir = self.disk_dir.clone();
let _ = self.save_state(&std::path::Path::new(&dir));
let _ = self.save_state(std::path::Path::new(&dir));
}
}
+4 -4
View File
@@ -559,7 +559,7 @@ impl RenderEvalHooks {
in_flight: &mut HashSet<usize>,
) -> NodeValue {
let mut payload = payload.clone();
for (_, value) in payload.params.iter_mut() {
for value in payload.params.values_mut() {
self.resolve_value(value, depth, in_flight);
}
match self.process_shader_job(&payload) {
@@ -584,7 +584,7 @@ impl RenderEvalHooks {
in_flight: &mut HashSet<usize>,
) -> Option<NodeValue> {
let mut payload = payload.clone();
for (_, value) in payload.values.iter_mut() {
for value in payload.values.values_mut() {
self.resolve_value(value, depth, in_flight);
}
@@ -843,7 +843,7 @@ impl RenderEvalHooks {
return None;
}
let nested = (unsafe { oak_node::jobs::shader_job(handle) }).cloned()?;
Some(self.process_shader_job_depth(&nested, depth + 1)?)
self.process_shader_job_depth(&nested, depth + 1)
});
let tex = tex?;
let (token, tex_size) = match &tex {
@@ -1797,7 +1797,7 @@ fn blend_transition(
// Fallback: without a blend (a missing side, or a shader job that
// could not run) show the side that natively covers `time` — the
// outgoing block before the cut, the incoming one at or after it.
Ok(blended.or_else(|| if progress < 0.5 { from } else { to }))
Ok(blended.or(if progress < 0.5 { from } else { to }))
}
/// Walk an adjustment block's effect chain to its head: the first node
+5
View File
@@ -100,6 +100,11 @@ pub unsafe fn get<T: Any>(h: &CHandle) -> Option<&T> {
/// `T` must be the boxed type, and the caller must guarantee the handle
/// is not concurrently borrowed (the C ABI contract: a handle passed by
/// value is exclusively owned for the duration of the call).
// The shared reference is the ABI input; exclusivity is the caller's
// `unsafe` contract above, so the lint's usual aliasing concern is
// discharged by the caller, not by `&mut CHandle` (which the C ABI does
// not pass).
#[allow(clippy::mut_from_ref)]
pub unsafe fn get_mut<T: Any>(h: &CHandle) -> Option<&mut T> {
if h.is_null() {
return None;
+6 -9
View File
@@ -287,9 +287,11 @@ pub struct HelloCapsMsg {
/// representation and are dropped by [`WireNodeValue::from_node_value`].
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(tag = "t", content = "v", rename_all = "snake_case")]
#[derive(Default)]
pub enum WireNodeValue {
/// No value.
None,
#[default]
None,
/// Integer.
Int(i64),
/// Float.
@@ -318,11 +320,6 @@ pub enum WireNodeValue {
Binary(Vec<u8>),
}
impl Default for WireNodeValue {
fn default() -> Self {
WireNodeValue::None
}
}
impl WireNodeValue {
/// The wire form of a node value, or `None` when the variant has no
@@ -1174,7 +1171,8 @@ impl FrameSlotPool {
if unsafe { (*header).magic } != FRAMEPOOL_MAGIC {
return FrameSlotPool::invalid();
}
let pool = unsafe {
unsafe {
FrameSlotPool {
base: mem,
header,
@@ -1183,8 +1181,7 @@ impl FrameSlotPool {
meta: mem.add((*header).meta_offset as usize) as *mut FrameSlotMeta,
data: mem.add((*header).data_offset as usize),
}
};
pool
}
}
/// An invalid pool (attach on a non-pool segment).
+3 -4
View File
@@ -1379,11 +1379,10 @@ impl ProcessDispatcher {
pub fn broadcast_plugin_cancel(&self) {
let mut inner = lock(&self.inner);
for handle in inner.workers.iter_mut() {
if matches!(handle.state, WorkerState::Alive | WorkerState::Starting) {
if self.send_json(handle, &plugin_cancel_json()).is_err() {
if matches!(handle.state, WorkerState::Alive | WorkerState::Starting)
&& self.send_json(handle, &plugin_cancel_json()).is_err() {
handle.state = WorkerState::Dead;
}
}
}
}
@@ -2386,7 +2385,7 @@ impl JobDispatch for ProcessDispatcher {
// Every ticket still open completes with cancellation; the map
// is dropped with the dispatcher (clear for hygiene — leaked
// entries pin shm region views).
for (_, pt) in inner.tickets.iter_mut() {
for pt in inner.tickets.values_mut() {
if let Some(done) = pt.done.take() {
fired.push((done, Err(Error::State)));
}