[vlc-commits] [Git][videolan/vlc][master] vlcrs-macros: simplify transmuting function pointers

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Aug 25 07:12:47 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
0f4f6806 by Alexandre Janniaux at 2024-08-25T06:41:02+00:00
vlcrs-macros: simplify transmuting function pointers

Clippy reports[^1] those transmute as being non-necessary, and it seems
that it now works correctly with `as *mut c_void` without the additional
template typing parameters.

[^1]: https://rust-lang.github.io/rust-clippy/master/index.html#/transmutes_expressible_as_ptr_casts

- - - - -


1 changed file:

- src/rust/vlcrs-macros/src/module.rs


Changes:

=====================================
src/rust/vlcrs-macros/src/module.rs
=====================================
@@ -939,10 +939,8 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
                     ::vlcrs_plugin::ModuleProperties::MODULE_CB_OPEN as _,
                     #module_open_with_nul,
                     unsafe {
-                        std::mem::transmute::<
-                            <#loader as ModuleProtocol<#type_>>::Activate,
-                            *mut std::ffi::c_void
-                        >(<#loader as ModuleProtocol<#type_>>::activate_function())
+                        <#loader as ModuleProtocol<#type_>>::activate_function()
+                        as *mut std::ffi::c_void
                     }
                 )
             } != 0
@@ -958,10 +956,8 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
                         ::vlcrs_plugin::ModuleProperties::MODULE_CB_CLOSE as _,
                         #module_close_with_nul,
                         unsafe {
-                            std::mem::transmute::<
-                                <#loader as ModuleProtocol<#type_>>::Deactivate,
-                                *mut std::ffi::c_void
-                            >(<#loader as ModuleProtocol<#type_>>::deactivate_function().unwrap())
+                            <#loader as ModuleProtocol<#type_>>::deactivate_function().unwrap()
+                            as *mut std::ffi::c_void
                         }
                     )
                 } != 0



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/0f4f6806d3626bd672af221c6ffd7b19b2f0a694

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/0f4f6806d3626bd672af221c6ffd7b19b2f0a694
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list