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

Types with flexible array member generic does not propagate to other types using the type #2939

Open
i509VCB opened this issue Sep 24, 2024 · 2 comments
Labels

Comments

@i509VCB
Copy link

i509VCB commented Sep 24, 2024

If a type has a flexible array member, any other types which use the type with a flexible array member in their own type does not have the generic for the flexible array member propagated.

For example, scan_params has an FAM (with a regex pass to wrap the FAM in a ManuallyDrop (see #2936):
https://github.com/i509VCB/nrf70/blob/issue/fam-bindgen/fw/bindings.rs#L3209-L3236

#[repr(C, packed)]
pub struct scan_params<FAM: ?Sized = [::core::ffi::c_uint; 0]> {
    #[doc = " If 0x1, RPU force passive scan on all channels"]
    pub passive_scan: ::core::ffi::c_ushort,
    #[doc = " Number of ssid's in scan_ssids parameter"]
    pub num_scan_ssids: ::core::ffi::c_uchar,
    #[doc = " Specific SSID's to scan for"]
    pub scan_ssids: [ssid; 2usize],
    #[doc = " used to send probe requests at non CCK rate in 2GHz band"]
    pub no_cck: ::core::ffi::c_uchar,
    #[doc = "  Bitmap of bands to be scanned. Value Zero will scan both 2.4 and 5 GHZ"]
    pub bands: ::core::ffi::c_uchar,
    #[doc = " Information element(s) data ie"]
    pub ie: ie,
    #[doc = " MAC address"]
    pub mac_addr: [::core::ffi::c_uchar; 6usize],
    #[doc = " Max scan duration in active scan. If zero rpu programs 50msec"]
    pub dwell_time_active: ::core::ffi::c_ushort,
    #[doc = " Max scan duration in passive scan. If zero rpu programs 150msec"]
    pub dwell_time_passive: ::core::ffi::c_ushort,
    #[doc = " Number of channels to be scanned"]
    pub num_scan_channels: ::core::ffi::c_ushort,
    #[doc = " If true, skip local and IANA Unicast reserved MACs"]
    pub skip_local_admin_macs: ::core::ffi::c_uchar,
    #[doc = " specific channels to be scanned"]
    pub center_frequency: ::core::mem::ManuallyDrop<FAM>,
}

But then scan_params when used in umac_scan_info, the FAM type is not expanded:
https://github.com/i509VCB/nrf70/blob/issue/fam-bindgen/fw/bindings.rs#L3489-L3495

#[repr(C, packed)]
pub struct umac_scan_info {
    #[doc = " scan type see &enum scan_reason"]
    pub scan_reason: ::core::ffi::c_int,
    #[doc = " scan parameters scan_params"]
    pub scan_params: scan_params,
}

Since the FAM type is not propagated to umac_scan_info, it is not possible to use the FAM parameter

Bindgen invocation:
https://github.com/i509VCB/nrf70/blob/issue/fam-bindgen/gen.py#L111-L124

@emilio emilio added the bug label Sep 25, 2024
@emilio
Copy link
Contributor

emilio commented Sep 25, 2024

cc @jsgf

@jsgf
Copy link
Contributor

jsgf commented Sep 27, 2024

Yeah I guess the DSTness of types need to propagate up to their containing structures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants