Skip to content
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

anyauthput: fix compiler warning on 64-bit Windows #2972

Closed
wants to merge 1 commit into from

Conversation

MarcelRaad
Copy link
Member

On Windows, the read function from <io.h> is used, which has its byte
count parameter as unsigned int instead of size_t [0].

The warning is visible in the autobuilds: https://curl.haxx.se/dev/log.cgi?id=20180910161513-27869#prob1

[0] https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/read

retcode = read(fd, ptr, size * nmemb);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about instead writing it in a way that only has the function call in one place?

#ifdef WIN32
#define READ_3RD_ARG unsigned int
#else 
#define READ_3RD_ARG size_t
#endif

  retcode = read(fd, ptr, (READ_3RD_ARG)(size * nmemb));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better, yes, and then it can also be integrated into the existing #ifdef. Thanks!

MarcelRaad added a commit to MarcelRaad/curl that referenced this pull request Sep 11, 2018
On Windows, the read function from <io.h> is used, which has its byte
count parameter as unsigned int instead of size_t.

Closes curl#2972
On Windows, the read function from <io.h> is used, which has its byte
count parameter as unsigned int instead of size_t.

Closes curl#2972
@MarcelRaad MarcelRaad deleted the anyauthput_warning branch September 12, 2018 10:27
@lock lock bot locked as resolved and limited conversation to collaborators Dec 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants