-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
bhyve/audio.c: avoid re-calculating the length of dev_name #945
Conversation
Source: usr.sbin/bhyve/audio.c In the function audio_init(), strlen() is being called two times, first to get the length of dev_name and second to use in memcpy(). Creating a local variable and keeping the length avoids this re-calculation. Signed-off-by: rilysh <nightquick@proton.me>
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.
Looks good to me.
usr.sbin/bhyve/audio.c
Outdated
@@ -80,15 +80,17 @@ audio_init(const char *dev_name, uint8_t dir) | |||
#endif | |||
}; | |||
#endif | |||
size_t sz; |
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'd prefer nlen to sz.
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.
Thanks! I've updated the name.
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.
This is ready to land.
In the function audio_init(), strlen() is being called two times, first to get the length of dev_name and second to use in memcpy(). Creating a local variable and keeping the length avoids this re-calculation. Signed-off-by: rilysh <nightquick@proton.me> Reviewed by: imp, zlei Pull Request: #945
This has landed. Thank you for your contribution. |
In the function audio_init(), strlen() is being called two times, first to get the length of dev_name and second to use in memcpy(). Creating a local variable and keeping the length avoids this re-calculation. Signed-off-by: rilysh <nightquick@proton.me> Reviewed by: imp, zlei Pull Request: freebsd/freebsd-src#945
In the function audio_init(), strlen() is being called two times, first to get the length of dev_name and second to use in memcpy(). Creating a local variable and keeping the length avoids this re-calculation.