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
+11 -9
View File
@@ -75,24 +75,27 @@ fn footage_decode_renders_known_content() {
let off = y * stride + x * 16;
let mut out = [0f32; 4];
for i in 0..4 {
out[i] = f32::from_le_bytes(
frame.data[off + i * 4..off + i * 4 + 4]
.try_into()
.unwrap(),
);
out[i] =
f32::from_le_bytes(frame.data[off + i * 4..off + i * 4 + 4].try_into().unwrap());
}
out
};
for &(x, y) in &[(8usize, 32usize), (20, 10)] {
let [r, g, b, a] = read(x, y);
assert!(r > 0.5, "left half red at ({x},{y}): {r}");
assert!(g < 0.4 && b < 0.4, "left half not red at ({x},{y}): {r},{g},{b}");
assert!(
g < 0.4 && b < 0.4,
"left half not red at ({x},{y}): {r},{g},{b}"
);
assert!(a > 0.9, "opaque at ({x},{y}): {a}");
}
for &(x, y) in &[(56usize, 32usize), (40, 50)] {
let [r, g, b, a] = read(x, y);
assert!(b > 0.5, "right half blue at ({x},{y}): {b}");
assert!(r < 0.4 && g < 0.4, "right half not blue at ({x},{y}): {r},{g},{b}");
assert!(
r < 0.4 && g < 0.4,
"right half not blue at ({x},{y}): {r},{g},{b}"
);
assert!(a > 0.9, "opaque at ({x},{y}): {a}");
}
@@ -131,7 +134,6 @@ fn footage_decode_fails_explainably_for_missing_file() {
(16, 16),
PixelFormat::F32,
)
.err()
.expect("decode of a missing file must fail");
.expect_err("decode of a missing file must fail");
let _ = err.code(); // explainable error, not a panic
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -11,7 +11,7 @@ fn filled_frame(size: (i32, i32), rgba: [f32; 4]) -> Texture {
Texture::wrap_frame(f)
}
fn pixel_at(frame: &oak_core::texture::Frame, x: usize, y: usize) -> [f32; 4] {
let stride = frame.linesize_bytes() as usize;
let stride = frame.linesize_bytes();
let at = y * stride + x * 16;
let mut out = [0f32; 4];
for c in 0..4 { out[c] = f32::from_le_bytes(frame.data[at + c*4..at + c*4 + 4].try_into().unwrap()); }
+1 -1
View File
@@ -11,7 +11,7 @@ fn filled_frame(size: (i32, i32), rgba: [f32; 4]) -> Texture {
Texture::wrap_frame(f)
}
fn pixel_at(frame: &oak_core::texture::Frame, x: usize, y: usize) -> [f32; 4] {
let stride = frame.linesize_bytes() as usize;
let stride = frame.linesize_bytes();
let at = y * stride + x * 16;
let mut out = [0f32; 4];
for c in 0..4 { out[c] = f32::from_le_bytes(frame.data[at + c*4..at + c*4 + 4].try_into().unwrap()); }
+2 -2
View File
@@ -11,7 +11,7 @@ fn filled_frame(size: (i32, i32), rgba: [f32; 4]) -> Texture {
Texture::wrap_frame(f)
}
fn pixel_at(frame: &oak_core::texture::Frame, x: usize, y: usize) -> [f32; 4] {
let stride = frame.linesize_bytes() as usize;
let stride = frame.linesize_bytes();
let at = y * stride + x * 16;
let mut out = [0f32; 4];
for c in 0..4 { out[c] = f32::from_le_bytes(frame.data[at + c*4..at + c*4 + 4].try_into().unwrap()); }
@@ -44,7 +44,7 @@ const BLACK: [f32; 4] = [0.0, 0.0, 0.0, 1.0];
/// Paint one RGBA pixel into a CPU frame (these F32 frames are 16 bytes a
/// pixel).
fn paint(frame: &mut oak_core::texture::Frame, x: usize, y: usize, rgba: [f32; 4]) {
let at = y * frame.linesize_bytes() as usize + x * 16;
let at = y * frame.linesize_bytes() + x * 16;
for (c, v) in rgba.iter().enumerate() {
frame.data[at + c * 4..at + c * 4 + 4].copy_from_slice(&v.to_le_bytes());
}
+1 -1
View File
@@ -11,7 +11,7 @@ fn filled_frame(size: (i32, i32), rgba: [f32; 4]) -> Texture {
Texture::wrap_frame(f)
}
fn pixel_at(frame: &oak_core::texture::Frame, x: usize, y: usize) -> [f32; 4] {
let stride = frame.linesize_bytes() as usize;
let stride = frame.linesize_bytes();
let at = y * stride + x * 16;
let mut out = [0f32; 4];
for c in 0..4 { out[c] = f32::from_le_bytes(frame.data[at + c*4..at + c*4 + 4].try_into().unwrap()); }
+1 -1
View File
@@ -11,7 +11,7 @@ fn filled_frame(size: (i32, i32), rgba: [f32; 4]) -> Texture {
Texture::wrap_frame(f)
}
fn pixel_at(frame: &oak_core::texture::Frame, x: usize, y: usize) -> [f32; 4] {
let stride = frame.linesize_bytes() as usize;
let stride = frame.linesize_bytes();
let at = y * stride + x * 16;
let mut out = [0f32; 4];
for c in 0..4 { out[c] = f32::from_le_bytes(frame.data[at + c*4..at + c*4 + 4].try_into().unwrap()); }
+1 -1
View File
@@ -18,7 +18,7 @@ fn filled_frame(size: (i32, i32), rgba: [f32; 4]) -> Texture {
Texture::wrap_frame(f)
}
fn pixel_at(frame: &oak_core::texture::Frame, x: usize, y: usize) -> [f32; 4] {
let stride = frame.linesize_bytes() as usize;
let stride = frame.linesize_bytes();
let at = y * stride + x * 16;
let mut out = [0f32; 4];
for c in 0..4 { out[c] = f32::from_le_bytes(frame.data[at + c*4..at + c*4 + 4].try_into().unwrap()); }
+1 -1
View File
@@ -47,7 +47,7 @@ fn gradient_frame_x(size: (i32, i32)) -> Texture {
Texture::wrap_frame(f)
}
fn pixel_at(frame: &oak_core::texture::Frame, x: usize, y: usize) -> [f32; 4] {
let stride = frame.linesize_bytes() as usize;
let stride = frame.linesize_bytes();
let at = y * stride + x * 16;
let mut out = [0f32; 4];
for c in 0..4 { out[c] = f32::from_le_bytes(frame.data[at + c*4..at + c*4 + 4].try_into().unwrap()); }