Skip to content

Mismatch between flag type and function argument for recvmmsg #2945

Closed
@ozgb

Description

@ozgb

The function recvmmsg for musl and emscripten has argument type c_uint for flags, but the flag types as defined in this package are c_int.

Problematic function definitions here:


flags: ::c_uint,

I encounted this when compiling a dependency that used libc:

#18 580.4    Compiling solana-streamer v1.10.40
#18 580.8 error[E0308]: mismatched types
#18 580.8   --> /root/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/solana-streamer-1.10.40/src/recvmmsg.rs:99:70
#18 580.8    |
#18 580.8 99 |         unsafe { libc::recvmmsg(sock_fd, &mut hdrs[0], count as u32, MSG_WAITFORONE, &mut ts) };
#18 580.8    |                                                                      ^^^^^^^^^^^^^^ expected `u32`, found `i32`
#18 580.8    |
#18 580.8 help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit
#18 580.8    |
#18 580.8 99 |         unsafe { libc::recvmmsg(sock_fd, &mut hdrs[0], count as u32, MSG_WAITFORONE.try_into().unwrap(), &mut ts) };
#18 580.8    |                                                                                    ++++++++++++++++++++
#18 580.8 
#18 580.9 For more information about this error, try `rustc --explain E0308`.
#18 580.9 error: could not compile `solana-streamer` due to previous error
#18 580.9 warning: build failed, waiting for other jobs to finish...
#18 601.8 error: build failed

MSG_WAITFORONE is defined as a c_int:

pub const MSG_WAITFORONE: ::c_int = 0x10000;

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions