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

avoid variable length arrays #15577

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

avoid variable length arrays #15577

wants to merge 2 commits into from

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Jan 16, 2025

Summary

cf. #15572

Impact

Testing

yamt added 2 commits January 16, 2025 13:33
use heap allocation instead.

variable length array is a C99 feature, which should not be used
in the common code. besides that, stack consumption with the
unchecked user-given size a bad idea in general.
@github-actions github-actions bot added Area: Networking Effects networking subsystem Arch: simulator Issues related to the SIMulator Board: simulator Size: S The size of the change in this PR is small labels Jan 16, 2025
@nuttxpr
Copy link

nuttxpr commented Jan 16, 2025

[Experimental Bot, please feedback here]

Fill In The Commit Message: This PR contains a Commit with an Empty Commit Message. Please fill in the Commit Message with the PR Summary.

Summary

This PR lacks a summary. The author needs to provide information on the necessity of the change, the affected functional code, the mechanics of the change, and related NuttX issues/PRs. Without this, it's impossible to determine if it meets requirements.

Impact

The impact assessment is entirely missing. The author needs to address all listed impact areas (user, build, hardware, documentation, security, compatibility) with either "NO" or a "YES" followed by a description. Without this, the PR doesn't meet requirements.

Testing

The testing section is incomplete. While the template is present, the author hasn't filled in any information about the build hosts, targets, or provided any testing logs before and after the change. This makes it impossible to assess if the changes work as intended and thus the PR does not meet the requirements.

@@ -142,9 +143,18 @@ static int do_sendto_request(FAR struct usrsock_conn_s *conn,
{
};

struct iovec bufs[2 + msg->msg_iovlen];
struct iovec *bufs;
Copy link
Contributor

Choose a reason for hiding this comment

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

FAR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops. thank you.

int i;

iovlen = 2 + msg->msg_iovlen;
bufs = kmm_malloc(sizeof(*bufs) * iovlen);
Copy link
Contributor

Choose a reason for hiding this comment

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

could we use alloca or save the buffer to conn? it isn't good to do the allocation in the hot path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i guess we can have a special case for small iovlen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: simulator Issues related to the SIMulator Area: Networking Effects networking subsystem Board: simulator Size: S The size of the change in this PR is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants