Skip to content

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

Closed
MarcelRaad wants to merge 1 commit into
curl:masterfrom
MarcelRaad:anyauthput_warning
Closed

MarcelRaad wants to merge 1 commit into
curl:masterfrom
MarcelRaad:anyauthput_warning

Conversation

@MarcelRaad

Copy link
Copy Markdown
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

Comment thread docs/examples/anyauthput.c Outdated

Copy link
Copy Markdown
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
Copy Markdown
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!

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.

2 participants