Replace strncpy with memcpy#9835
Draft
hyunjiki-amd wants to merge 5 commits into
Draft
Conversation
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
Collaborator
Author
|
Will remove src/runtime_src/core/edge/drm changes as they're Linux drivers https://github.com/Xilinx/XRT/blob/master/src/runtime_src/core/edge/drm/README |
stsoe
reviewed
May 25, 2026
Collaborator
stsoe
left a comment
There was a problem hiding this comment.
Hi @hyunjiki-amd . You cannot change Linux driver code. So most of this PR is not valid.
stsoe
reviewed
May 25, 2026
Collaborator
stsoe
left a comment
There was a problem hiding this comment.
Please follow this pattern instead of if conditions
auto len = std::min(name_str.size(), sizeof(device_props.name) - 1);
std::memcpy(device_props.name, name_str.data(), len);
device_props.name[len] = '\0';
Comment on lines
+132
to
+136
| size_t len = name_str.length(); | ||
| if (len >= sizeof(device_props.name)) | ||
| len = sizeof(device_props.name) - 1; | ||
| std::memcpy(device_props.name, name_str.c_str(), len); | ||
| device_props.name[len] = '\0'; |
Collaborator
There was a problem hiding this comment.
Suggested change
| size_t len = name_str.length(); | |
| if (len >= sizeof(device_props.name)) | |
| len = sizeof(device_props.name) - 1; | |
| std::memcpy(device_props.name, name_str.c_str(), len); | |
| device_props.name[len] = '\0'; | |
| auto len = std::min(name_str.size(), sizeof(device_props.name) - 1); | |
| std::memcpy(device_props.name, name_str.data(), len); | |
| device_props.name[len] = '\0'; |
Collaborator
There was a problem hiding this comment.
Do not forget to sign all commits. git commit -s ...
Signed-off-by: Hyunji Kim <Hyunji.Kim@amd.com>
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
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! 👍" |
1 similar comment
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 (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