Skip to content

Replace strcpy with memcpy#9834

Draft
hyunjiki-amd wants to merge 3 commits into
Xilinx:masterfrom
hyunjiki-amd:banned-api-3
Draft

Replace strcpy with memcpy#9834
hyunjiki-amd wants to merge 3 commits into
Xilinx:masterfrom
hyunjiki-amd:banned-api-3

Conversation

@hyunjiki-amd
Copy link
Copy Markdown
Collaborator

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

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown
Collaborator

@stsoe stsoe 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 change Linux driver code, please

{
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);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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>
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@stsoe stsoe added the do not merge hold off on merging label May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge hold off on merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants