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 using variable-length array #14

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

ericlinsechs
Copy link
Contributor

Using variable-length array is not a good call
(https://lkml.org/lkml/2011/10/23/25). So remove it.

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Check https://cbea.ms/git-commit/ carefully and refine the git commit message.

Hyperlinks should appear at the end of git commit message.

@ericlinsechs
Copy link
Contributor Author

I have corrected the commit message. Could you please review it? Thank you.

@jserv
Copy link
Contributor

jserv commented Jun 12, 2024

I have corrected the commit message. Could you please review it? Thank you.

You don't have to leave the above message. Simply click "Re-request review" via GitHub web page.
See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Don't place "Link: https://lkml.org/lkml/2011/10/23/25", which does not express the rationale. You can quote some insights from the LKML.

@ericlinsechs ericlinsechs requested a review from jserv June 12, 2024 07:53
client.c Outdated Show resolved Hide resolved
client.c Outdated Show resolved Hide resolved
fibdrv.c Outdated
long long f[k + 2];
long long *f = kmalloc(sizeof(*f) * (k + 2), GFP_KERNEL);
if (!f)
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

The return value -1 should be documented, otherwise it is nonsensical as for the math definition.

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 supposed errno would be appropriate to describe the situation?

return -ENOMEM;

long long f[k + 2];
long long *f = kmalloc(sizeof(*f) * (k + 2), GFP_KERNEL);
if (!f)
return -ENOMEM;
Copy link
Contributor

Choose a reason for hiding this comment

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

Provide explicit comments for this function.

The size is always valid, but variable-length arrays generate worse code
for no good reason, unless the function happens to be inlined and the
compiler sees the length for the simple constant it is.

Signed-off-by: Eric Lin <[email protected]>
@ericlinsechs ericlinsechs requested a review from jserv June 12, 2024 10:13
@jserv jserv merged commit d09711e into sysprog21:master Jun 12, 2024
2 checks passed
@jserv
Copy link
Contributor

jserv commented Jun 12, 2024

Thank @ericlinsechs for contributing!

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.

2 participants