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

recvmsg: take slice for cmsg_buffer #2524

Merged
merged 1 commit into from
Oct 22, 2024
Merged

Conversation

erenon
Copy link
Contributor

@erenon erenon commented Oct 22, 2024

Instead of a Vec, to avoid forcing an allocation.

cmsg_space! now creates a zero initialized vec (instead of a zero-len vec with capacity): this way callsites do not need to be changed.

I tried to change cmsg_space! to create a fixed sized array (instead of a Vec) but run into:

error: constant expression depends on a generic parameter
    --> test/sys/test_socket.rs:2907:26
     |
2907 |         let mut cspace = cmsg_space!(libc::sock_extended_err, SA);
     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Fixes #2523

Instead of a Vec, to avoid forcing an allocation.

`cmsg_space!` now creates a zero initialized vec
(instead of a zero-len vec with capacity):
this way callsites do not need to be changed.

Fixes nix-rust#2523
Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the patch!

@SteveLauC SteveLauC added this pull request to the merge queue Oct 22, 2024
Merged via the queue into nix-rust:master with commit b91bf39 Oct 22, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

recvmsg should take &mut [u8] instead of &mut Vec<u8> for cmsg_buffer
2 participants