Skip to contentSkip to conversation

rust: bindings: allow any number of params

PATCH In review Michael S. Tsirkin 4 participants 4 messages Jul 15, 2025 Rust

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rust: bindings: allow any number of params

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)]

---
 rust/qemu-api/src/bindings.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
rust/qemu-api/src/bindings.rs +2 -1
index 057de4b646..c4f1f755ce 100644
@@ -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.
Signature · 1 line
MST
Reviewed-by on v2 1/1
#1 lore raw
Quoted 20 lines · Michael S. Tsirkin

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]> {
      | |____________________________________________^
      |
Quoted 8 lines

= 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)]

---
  rust/qemu-api/src/bindings.rs | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Acked-by on v2 1/1
#2 lore raw
In reply to Michael S. Tsirkin

Il mar 15 lug 2025, 08:20 Michael S. Tsirkin <[email protected]> ha scritto:

Quoted 6 lines

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.

Quoted 7 lines

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

     |
Quoted 39 lines
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)]

---
 rust/qemu-api/src/bindings.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
rust/qemu-api/src/bindings.rs +2 -2
index 057de4b646..c4f1f755ce 100644
@@ -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 on v2 1/1
#3 lore raw
In reply to Michael S. Tsirkin
Quoted 45 lines · Michael S. Tsirkin

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)]

---
 rust/qemu-api/src/bindings.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
rust/qemu-api/src/bindings.rs +2 -2
index 057de4b646..c4f1f755ce 100644
@@ -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.
--
Quoted 2 lines

MST