Replace strcpy with memcpy#9834
Draft
hyunjiki-amd wants to merge 3 commits into
Draft
Conversation
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
stsoe
reviewed
May 26, 2026
Collaborator
stsoe
left a comment
There was a problem hiding this comment.
Don't change Linux driver code, please
stsoe
requested changes
May 26, 2026
| { | ||
| if(strlen(mName.c_str()) < 256)//info.mName is static array of size 256 | ||
| std::strcpy(info.mName, mName.c_str()); | ||
| std::memcpy(info.mName, mName.c_str(), strlen(mName.c_str()) + 1); |
Collaborator
There was a problem hiding this comment.
This does not look the same. I think you should replace with
Suggested change
| std::memcpy(info.mName, mName.c_str(), strlen(mName.c_str()) + 1); | |
| const auto len = std::min(mName.size(), sizeof(info.mName) - 1); | |
| std::memcpy(info.mName, mName.data(), len); | |
| info.mName[len] = '\0'; |
too bad it's so verbose, but so be it.
Signed-off-by: Hyunji Kim <Hyunji.Kim@amd.com>
Signed-off-by: Hyunji Kim <Hyunji.Kim@amd.com>
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem solved by the commit
To meet the driver compliance, banned APIs must be replaced according to https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28719-banned-api-usage-use-updated-function-replacement
Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered
Issue fixed: driver compliance
How problem was solved, alternative solutions (if any) and why they were rejected
Replace deprecated APIs in core/common (e.g., strncpy to memcpy)
Risks (if any) associated the changes in the commit
None
What has been tested and how, request additional testing if necessary
Confirmed that the build is successful with the changes locally
Documentation impact (if any)
None
Signed-off-by: Hyunji Kim Hyunji.Kim@amd.com