[PATCH v2] rust: bindings: allow any number of params

Michael S. Tsirkin posted 1 patch 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/e41344bd22248b0883752ef7a7c459090a3d9cfc.1752560127.git.mst@redhat.com
Maintainers: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
rust/qemu-api/src/bindings.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH v2] rust: bindings: allow any number of params
Posted by Michael S. Tsirkin 4 months ago
We are going to be adding more parameters, and this makes
rust unhappy:
    Functions with lots of parameters are considered bad style and reduce
    readability (“what does the 5th parameter mean?”). Consider grouping
    some parameters into a new type.

Specifically:

error: this function has too many arguments (8/7)
    --> /builds/mstredhat/qemu/build/rust/qemu-api/rust-qemu-api-tests.p/structured/bindings.inc.rs:3840:5
     |
3840 | /     pub fn new_bitfield_1(
3841 | |         secure: std::os::raw::c_uint,
3842 | |         space: std::os::raw::c_uint,
3843 | |         user: std::os::raw::c_uint,
...    |
3848 | |         address_type: std::os::raw::c_uint,
3849 | |     ) -> __BindgenBitfieldUnit<[u8; 4usize]> {
     | |____________________________________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
     = note: `-D clippy::too-many-arguments` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 rust/qemu-api/src/bindings.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/qemu-api/src/bindings.rs b/rust/qemu-api/src/bindings.rs
index 057de4b646..c4f1f755ce 100644
--- a/rust/qemu-api/src/bindings.rs
+++ b/rust/qemu-api/src/bindings.rs
@@ -13,7 +13,8 @@
     clippy::missing_const_for_fn,
     clippy::ptr_offset_with_cast,
     clippy::useless_transmute,
-    clippy::missing_safety_doc
+    clippy::missing_safety_doc,
+    clippy::too_many_arguments
 )]
 
 //! `bindgen`-generated declarations.
-- 
MST


Re: [PATCH v2] rust: bindings: allow any number of params
Posted by Manos Pitsidianakis 4 months ago
On Tue, Jul 15, 2025 at 9:15 AM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> We are going to be adding more parameters, and this makes
> rust unhappy:
>     Functions with lots of parameters are considered bad style and reduce
>     readability (“what does the 5th parameter mean?”). Consider grouping
>     some parameters into a new type.
>
> Specifically:
>
> error: this function has too many arguments (8/7)
>     --> /builds/mstredhat/qemu/build/rust/qemu-api/rust-qemu-api-tests.p/structured/bindings.inc.rs:3840:5
>      |
> 3840 | /     pub fn new_bitfield_1(
> 3841 | |         secure: std::os::raw::c_uint,
> 3842 | |         space: std::os::raw::c_uint,
> 3843 | |         user: std::os::raw::c_uint,
> ...    |
> 3848 | |         address_type: std::os::raw::c_uint,
> 3849 | |     ) -> __BindgenBitfieldUnit<[u8; 4usize]> {
>      | |____________________________________________^
>      |
>      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
>      = note: `-D clippy::too-many-arguments` implied by `-D warnings`
>      = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  rust/qemu-api/src/bindings.rs | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/rust/qemu-api/src/bindings.rs b/rust/qemu-api/src/bindings.rs
> index 057de4b646..c4f1f755ce 100644
> --- a/rust/qemu-api/src/bindings.rs
> +++ b/rust/qemu-api/src/bindings.rs
> @@ -13,7 +13,8 @@
>      clippy::missing_const_for_fn,
>      clippy::ptr_offset_with_cast,
>      clippy::useless_transmute,
> -    clippy::missing_safety_doc
> +    clippy::missing_safety_doc,
> +    clippy::too_many_arguments
>  )]
>
>  //! `bindgen`-generated declarations.
> --
> MST
>

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Re: [PATCH v2] rust: bindings: allow any number of params
Posted by Paolo Bonzini 4 months ago
Il mar 15 lug 2025, 08:20 Michael S. Tsirkin <mst@redhat.com> ha scritto:

> We are going to be adding more parameters, and this makes
> rust unhappy:
>     Functions with lots of parameters are considered bad style and reduce
>     readability (“what does the 5th parameter mean?”). Consider grouping
>     some parameters into a new type.
>
> Specifically:
>
> error: this function has too many arguments (8/7)
>     -->
> /builds/mstredhat/qemu/build/rust/qemu-api/rust-qemu-api-tests.p/structured/bindings.inc.rs:3840
> :5
>

Acked-by: Paolo Bonzini <pbonzini@redhat.com>


     |
> 3840 | /     pub fn new_bitfield_1(
> 3841 | |         secure: std::os::raw::c_uint,
> 3842 | |         space: std::os::raw::c_uint,
> 3843 | |         user: std::os::raw::c_uint,
> ...    |
> 3848 | |         address_type: std::os::raw::c_uint,
> 3849 | |     ) -> __BindgenBitfieldUnit<[u8; 4usize]> {
>      | |____________________________________________^
>      |
>      = help: for further information visit
> https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
>      = note: `-D clippy::too-many-arguments` implied by `-D warnings`
>      = help: to override `-D warnings` add
> `#[allow(clippy::too_many_arguments)]`
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  rust/qemu-api/src/bindings.rs | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/rust/qemu-api/src/bindings.rs b/rust/qemu-api/src/bindings.rs
> index 057de4b646..c4f1f755ce 100644
> --- a/rust/qemu-api/src/bindings.rs
> +++ b/rust/qemu-api/src/bindings.rs
> @@ -13,7 +13,8 @@
>      clippy::missing_const_for_fn,
>      clippy::ptr_offset_with_cast,
>      clippy::useless_transmute,
> -    clippy::missing_safety_doc
> +    clippy::missing_safety_doc,
> +    clippy::too_many_arguments
>  )]
>
>  //! `bindgen`-generated declarations.
> --
> MST
>
>
>
Re: [PATCH v2] rust: bindings: allow any number of params
Posted by Philippe Mathieu-Daudé 4 months ago
On 15/7/25 08:15, Michael S. Tsirkin wrote:
> We are going to be adding more parameters, and this makes
> rust unhappy:
>      Functions with lots of parameters are considered bad style and reduce
>      readability (“what does the 5th parameter mean?”). Consider grouping
>      some parameters into a new type.
> 
> Specifically:
> 
> error: this function has too many arguments (8/7)
>      --> /builds/mstredhat/qemu/build/rust/qemu-api/rust-qemu-api-tests.p/structured/bindings.inc.rs:3840:5
>       |
> 3840 | /     pub fn new_bitfield_1(
> 3841 | |         secure: std::os::raw::c_uint,
> 3842 | |         space: std::os::raw::c_uint,
> 3843 | |         user: std::os::raw::c_uint,
> ...    |
> 3848 | |         address_type: std::os::raw::c_uint,
> 3849 | |     ) -> __BindgenBitfieldUnit<[u8; 4usize]> {
>       | |____________________________________________^
>       |
>       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
>       = note: `-D clippy::too-many-arguments` implied by `-D warnings`
>       = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>   rust/qemu-api/src/bindings.rs | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>