xiaoxiang781216 commented on code in PR #3601:
URL: https://github.com/apache/nuttx-apps/pull/3601#discussion_r3563089080
##########
examples/udgram/udgram_client.c:
##########
@@ -91,14 +91,10 @@ int main(int argc, FAR char *argv[])
/* Set up the server address */
- addrlen = sizeof(CONFIG_EXAMPLES_UDGRAM_ADDR);
- if (addrlen > UNIX_PATH_MAX)
- {
- addrlen = UNIX_PATH_MAX;
- }
+ addrlen = strnlen(CONFIG_EXAMPLES_UDGRAM_ADDR, UNIX_PATH_MAX - 1);
Review Comment:
why need call strnlen in runtime if CONFIG_EXAMPLES_UDGRAM_ADDR?
##########
examples/udgram/udgram_server.c:
##########
@@ -93,14 +93,10 @@ int main(int argc, FAR char *argv[])
/* Bind the socket to a local address */
- addrlen = sizeof(CONFIG_EXAMPLES_UDGRAM_ADDR);
- if (addrlen > UNIX_PATH_MAX)
- {
- addrlen = UNIX_PATH_MAX;
- }
+ addrlen = strnlen(CONFIG_EXAMPLES_UDGRAM_ADDR, UNIX_PATH_MAX - 1);
Review Comment:
ditto
##########
examples/ustream/ustream_server.c:
##########
@@ -80,15 +80,10 @@ int main(int argc, char *argv[])
/* Bind the socket to a local address */
- addrlen = sizeof(CONFIG_EXAMPLES_USTREAM_ADDR);
- if (addrlen > UNIX_PATH_MAX)
- {
- addrlen = UNIX_PATH_MAX;
- }
+ addrlen = strnlen(CONFIG_EXAMPLES_USTREAM_ADDR, UNIX_PATH_MAX - 1);
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]