-
Notifications
You must be signed in to change notification settings - Fork 749
Provided changes to enable building of this file with both clang and … #1527
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
Conversation
loganek
left a comment
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.
Having #ifdef __cplusplus in .c files is a bi unusual; could you tell us about your usecase and explain why C file is compiled with C++ compiler?
|
We are running WolfSSL into Wasm (look here -> https://github.com/JamesMenetrey/wolfssl-examples/tree/wasm/Wasm) and at the same time I need some features from C++. |
| __wasi_addr_t wasi_addr {} ; | ||
| #else | ||
| __wasi_addr_t wasi_addr = { 0 }; | ||
| #endif |
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.
@dzobbe Shall we use memset to initialize it here so as to avoid introducing __cplusplus?
__wasi_addr_t wasi_addr;
...
memset(&wasi_addr, 0, sizeof(wasi_addr));| __wasi_addr_t wasi_addr {} ; | ||
| #else | ||
| __wasi_addr_t wasi_addr = { 0 }; | ||
| #endif |
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
|
|
||
| switch (optname) { | ||
| case SO_RCVTIMEO: | ||
| case SO_RCVTIMEO: { |
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.
Should put { to the next line, or CI code guideline check will report error:
case SO_RCVTIMEO:
{
assert(optlen == sizeof(struct timeval));
timeout_us = timeval_to_time_us(*(struct timeval *)optval);
error = __wasi_sock_set_recv_timeout(sockfd, timeout_us);
HANDLE_ERROR(error);
return error;
}|
Done. Thank you. |
| { | ||
| __wasi_addr_t wasi_addr = { 0 }; | ||
| __wasi_addr_t wasi_addr; | ||
| memset(&wasi_addr, 0, sizeof(wasi_addr)); |
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 put memset after line 144 (had better make it a line with an empty line above and below), here it is C source code, we usually align with the C coding style.
| { | ||
| __wasi_addr_t wasi_addr = { 0 }; | ||
| __wasi_addr_t wasi_addr; | ||
| memset(&wasi_addr, 0, sizeof(wasi_addr)); |
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.
|
Take a look now |
| } | ||
|
|
||
| aibuf_res = calloc(1, addr_info_size * sizeof(struct aibuf)); | ||
| aibuf_res = (aibuf *) calloc(1, addr_info_size * sizeof(struct aibuf)); |
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.
Should be (struct aibuf *), or compilation error occurs in Ubuntu.
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.
this is done
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.
Yes, and please help format the coding style by using clang-format-12:
clang-format-12 -i --style=file <this file>
@dzobbe One comment from me. And also could you please use clang-format-12 to format the code: Use |
| memset(&wasi_addr, 0, sizeof(wasi_addr)); | ||
|
|
||
| error = __wasi_sock_accept(sockfd, 0, &new_sockfd); | ||
| error = __wasi_sock_accept(sockfd, &new_sockfd); |
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.
Should not change this line, refer to: #1531
|
LGTM |
…lliance#1527) Enable to run WolfSSL into wasm and need some features from C++: https://github.com/JamesMenetrey/wolfssl-examples/tree/wasm/Wasm
…clang++