Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coreaudio-sys-utils fails cargo clippy due to missing unsafe tags #237

Open
mutexlox-signal opened this issue Oct 8, 2024 · 0 comments
Open

Comments

@mutexlox-signal
Copy link
Contributor

#236 initially turned on clippy on coreaudio-sys-utils, where it had not previously run, revealing a number of missing unsafe annotations on functions in coreaudio-sys-utils. Merely adding the unsafe annotations is insufficient to fix the issue, because calls to the functions also need the unsafe annotation around not only the function call to the unsafe function, but likely also need unsafe tags themselves, because their AudioUnit parameter is a raw pointer, and so safety depends on that pointer being valid.

See https://rust-lang.github.io/rust-clippy/master/index.html#/not_unsafe_ptr_arg_deref

$ cargo clippy -- -D warnings
    Checking coreaudio-sys-utils v0.1.0 (/Users/miriam/cubeb-coreaudio-rs/coreaudio-sys-utils)
error: this public function might dereference a raw pointer but is not marked `unsafe`
  --> coreaudio-sys-utils/src/audio_device_extensions.rs:23:58
   |
23 |     unsafe { AudioDeviceDuck(in_device, in_ducked_level, in_start_time, in_ramp_duration) }
   |                                                          ^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref
   = note: `#[deny(clippy::not_unsafe_ptr_arg_deref)]` on by default

error: this public function might dereference a raw pointer but is not marked `unsafe`
  --> coreaudio-sys-utils/src/audio_unit.rs:20:13
   |
20 |             unit,
   |             ^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
  --> coreaudio-sys-utils/src/audio_unit.rs:43:13
   |
43 |             unit,
   |             ^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
  --> coreaudio-sys-utils/src/audio_unit.rs:65:13
   |
65 |             unit,
   |             ^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
  --> coreaudio-sys-utils/src/audio_unit.rs:86:13
   |
86 |             unit,
   |             ^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:105:36
    |
105 |     unsafe { AudioUnitSetParameter(unit, id, scope, element, value, buffer_offset_in_frames) }
    |                                    ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:111:34
    |
111 |     unsafe { AudioUnitInitialize(unit) }
    |                                  ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:117:36
    |
117 |     unsafe { AudioUnitUninitialize(unit) }
    |                                    ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:122:44
    |
122 |     unsafe { AudioComponentInstanceDispose(unit) }
    |                                            ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:128:35
    |
128 |     unsafe { AudioOutputUnitStart(unit) }
    |                                   ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:134:34
    |
134 |     unsafe { AudioOutputUnitStop(unit) }
    |                                  ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:148:13
    |
148 |             in_unit,
    |             ^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:170:43
    |
170 |     unsafe { AudioUnitAddPropertyListener(unit, id, Some(listener), data as *mut c_void) }
    |                                           ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: this public function might dereference a raw pointer but is not marked `unsafe`
   --> coreaudio-sys-utils/src/audio_unit.rs:182:53
    |
182 |         AudioUnitRemovePropertyListenerWithUserData(unit, id, Some(listener), data as *mut c_void)
    |                                                     ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

error: redundant closure
  --> coreaudio-sys-utils/src/dispatch.rs:35:43
   |
35 |     get_serial_queue_singleton().run_sync(|| work()).unwrap()
   |                                           ^^^^^^^^^ help: replace the closure with the function itself: `work`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
   = note: `-D clippy::redundant-closure` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]`

error: redundant closure
  --> coreaudio-sys-utils/src/dispatch.rs:42:47
   |
42 |     match run_serially(|| panic::catch_unwind(|| work())) {
   |                                               ^^^^^^^^^ help: replace the closure with the function itself: `work`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

error: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`)
   --> coreaudio-sys-utils/src/string.rs:105:13
    |
105 |             ptr::null_mut() as *mut u8,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr::null_mut()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `-D clippy::unnecessary-cast` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]`

error: could not compile `coreaudio-sys-utils` (lib) due to 17 previous errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant