-
Notifications
You must be signed in to change notification settings - Fork 594
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
apps/examples: Add net local test sample #4171
base: master
Are you sure you want to change the base?
Conversation
Target : [c01bebd2abc2604a44df490907dff18c3dc07cf0] - Code Rule Check OK. |
Target : [c01bebd2abc2604a44df490907dff18c3dc07cf0] - Code Rule Check (C++) OK. |
Target : [5c3408b8e2b5f2edc0a398f4798ba3dc652aa3db] - Code Rule Check OK. |
Target : [5c3408b8e2b5f2edc0a398f4798ba3dc652aa3db] - Code Rule Check (C++) OK. |
strcpy(server_sun.sun_path, server_path); | ||
len = offsetof(struct sockaddr_un, sun_path) + strlen(server_sun.sun_path); |
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.
size_t len = strlen(server_sun.sun_path);
strncpy(server_sun.sun_path, server_path, len);
should we use offsetof here?
lwip using whole of structure itself, aligning with lwip will be better.
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.
I can't understand this comment. Would you explain more?
write(sockfd, (const void *)str, strlen(str)); | ||
|
||
n = read(sockfd, buf, MAXLINE); | ||
if (n < 0) { |
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.
if (n != MAXLINE) ?
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.
n
is always <= MAXLINE
. So n != MAXLINE
is not needed
char buf[MAXLINE + 1]; | ||
while (1) { | ||
n = read(sockfd, buf, MAXLINE); | ||
if (n < 0) { |
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.
same as above.
Target : [82c864a46b5c67b3a2bd0c50c64b796f1a555a2b] - Code Rule Check OK. |
Target : [82c864a46b5c67b3a2bd0c50c64b796f1a555a2b] - Code Rule Check (C++) OK. |
Target : [63c3837594030714c3f87eb74f7e581266bf7a32] - Code Rule Check OK. |
Target : [63c3837594030714c3f87eb74f7e581266bf7a32] - Code Rule Check (C++) OK. |
Target : [d848d4ae084773a8f966723309bb1c6adec1284a] - Code Rule Check OK. |
Target : [d848d4ae084773a8f966723309bb1c6adec1284a] - Code Rule Check (C++) OK. |
Target : [d0eac22a4e89f76749cfbea7e36f145e782eef5e] - Code Rule Check (C++) OK. |
Target : [d0eac22a4e89f76749cfbea7e36f145e782eef5e] - Code Rule Check OK. |
Target : [9a88da1675bc2c871bce63a75e530809a849ddff] - Code Rule Check (C++) OK. |
Target : [9a88da1675bc2c871bce63a75e530809a849ddff] - Code Rule Check OK. |
Target : [3f55373] - Code Rule Check (C++) OK. |
Target : [3f55373] - Code Rule Check OK. |
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.
It looks good, Please consider TJ's comment
|
||
#include "net_local.h" | ||
|
||
int client_talk(int sockfd, const char *func, const char *str) |
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.
Isn't it local function?
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.
looks good.
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.
it looks good to me.
Target : [3f55373] - Code Rule Check OK. |
No description provided.