-
Notifications
You must be signed in to change notification settings - Fork 288
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
openamp: replace all strncpy to strlcpy #602
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,7 +141,7 @@ int rpmsg_send_ns_message(struct rpmsg_endpoint *ept, unsigned long flags) | |
|
||
ns_msg.flags = flags; | ||
ns_msg.addr = ept->addr; | ||
strncpy(ns_msg.name, ept->name, sizeof(ns_msg.name)); | ||
strlcpy(ns_msg.name, ept->name, sizeof(ns_msg.name)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ret = rpmsg_send_offchannel_raw(ept, ept->addr, | ||
RPMSG_NS_EPT_ADDR, | ||
&ns_msg, sizeof(ns_msg), true); | ||
|
@@ -305,7 +305,7 @@ void rpmsg_register_endpoint(struct rpmsg_device *rdev, | |
rpmsg_ept_cb cb, | ||
rpmsg_ns_unbind_cb ns_unbind_cb, void *priv) | ||
{ | ||
strncpy(ept->name, name ? name : "", sizeof(ept->name)); | ||
strlcpy(ept->name, name ? name : "", sizeof(ept->name)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should create our own strncpy. char *safe_strncpy(char *dest, char *src, size_t size) {
size_t len;
if (size == 0) {
dest[0] = '\0';
} else {
len = strnlen(src, size - 1);
memcpy(dest, src, len);
dest[len] = '\0';
}
return dest;
} @edmooring, @tnmysh : any opinon/suggestion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that makes sense. In kernel as well, strlcpy was deprecated, and strscpy was introduced. https://www.kernel.org/doc/html/latest/core-api/kernel-api.html?highlight=declare_bitmap#c.strscpy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am okay, to introduce such function. |
||
ept->refcnt = 1; | ||
ept->addr = src; | ||
ept->dest_addr = dest; | ||
|
@@ -385,3 +385,11 @@ void rpmsg_destroy_ept(struct rpmsg_endpoint *ept) | |
(void)rpmsg_send_ns_message(ept, RPMSG_NS_DESTROY); | ||
rpmsg_unregister_endpoint(ept); | ||
} | ||
|
||
int rpmsg_notify_wait(struct rpmsg_device *rdev, uint32_t id) | ||
{ | ||
if (rdev->notify_wait_cb) | ||
return rdev->notify_wait_cb(rdev, id); | ||
|
||
return RPMSG_ERR_NXIO; | ||
} |
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.
Please introduce this commit in a new PR, you also need to provide more information to explain why you need this update.