-
Notifications
You must be signed in to change notification settings - Fork 335
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
Conversation
There was a problem hiding this 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.
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. |
There was a problem hiding this 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.
fibdrv.c
Outdated
long long f[k + 2]; | ||
long long *f = kmalloc(sizeof(*f) * (k + 2), GFP_KERNEL); | ||
if (!f) | ||
return -1; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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]>
Thank @ericlinsechs for contributing! |
Using variable-length array is not a good call
(https://lkml.org/lkml/2011/10/23/25). So remove it.