-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
mbed TLS 1.3: Fix compilation warnings with VS2015 x64 #999
Changes from all commits
83081c5
2a0344f
c4b659c
e8c587e
5ad6be7
28d7d3a
e4fd1ba
eb01d3c
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 |
---|---|---|
|
@@ -57,8 +57,10 @@ | |
#include <unistd.h> | ||
#else | ||
#include <io.h> | ||
#define read _read | ||
#define write _write | ||
#define read(fd, buf, len) \ | ||
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. personally, I think the MACRO checks should be different, to make it more readable(although this is not part of this PR):
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. ok, I think I will skip this change for this PR. |
||
_read( fd, (void *)( buf ), (unsigned int)( len ) ) | ||
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. Theoretically, we could lose data here. parameter 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. Yes, we could. In fact, I copied this code from the development branch: https://github.com/ARMmbed/mbedtls/blob/development/library/net_sockets.c#L67. I do not think this is a major problem as this is only sample code (even the net_sockets.c), but perhaps we could improve the quality of this code. Do you think I should raise an issue on this or fix it here? 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. Yes, we should raise an issue for this, but if possible, fis it here while we are modifying this file 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. The problem in this case is that in Unix we use the function read() while in Windows we use the function _read. Annoyingly the signature for these two functions is different, hence why we use the cast in the Window case as the type of 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. at least comment this, so people using this sample code would be aware of this risk |
||
#define write(fd, buf, len) \ | ||
_write( fd, (const void *)( buf ), (unsigned int)( len ) ) | ||
#endif | ||
|
||
#if defined(_WIN32) || defined(_WIN32_WCE) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1791,7 +1791,7 @@ int main( int argc, char *argv[] ) | |
unsigned char *larger_buf; | ||
|
||
ori_len = ret; | ||
extra_len = ssl_get_bytes_avail( &ssl ); | ||
extra_len = (int) ssl_get_bytes_avail( &ssl ); | ||
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 think it is better to change 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 think that is a good idea, however everything I have done here is backport the fix from the development branch. Do you think I should try to fix the problem here or raise another issue to address this in all the 3 branches? 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 think both:) 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. @RonEld: Even if we change this to size_t we will eventually need to cast as the return type of |
||
|
||
larger_buf = polarssl_malloc( ori_len + extra_len + 1 ); | ||
if( larger_buf == NULL ) | ||
|
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.
we should consider changing
tail_len
tosize_t
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 looked at the code again and I think that if we change this to size_t we will eventually need to use casts back to int. The problem is that functions such as
snprintf()
return int. Also, note that all the input parameters, etc are of type int so its not that straight forward to change one type. I think its best if we just investigate these problems as part of #1007