Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libcurl-thread.3: Clarify CURLOPT_NOSIGNAL takes long value 1L
- Loading branch information
Showing
1 changed file
with
3 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4673094
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.
@bagder I've since noticed the doc for
CURLOPT_NOSIGNAL
says use1
as well instead of what I would expect1L
. I was under the impression after some investigating I did in #346 that if the value type islong
it must be explicit because that could be an issue for some platforms with va_args. In Windows long and int are the same width and there's no difference but I'm curious about the details surrounding this behavior for other platforms. I'm now noticing places in the code where integers are used, see the protocol flags for example, and I did something similar myself when I added a flag to ssl options.4673094
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, all the numerical varargs take longs and we should make sure to mention
long
or use L suffixes in the documentation.4673094
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.
@bagder can you clarify, is it acceptable for options that only have a single arg value to pass an
int
instead of along
? I know it can be a problem for options that take multiple arg values. As I said I can see in the code that the flags used as values for some options that specify long values are basically ints (ie 1<<1) which would imply that it's acceptable.My concern is the user may not pass the correct type. Although you could argue user error here I'd say it's generally assumed that when you pass a value 1 to functions that take a long that value becomes a long instead of staying as an integer as is the case here due to va args. For example take CURLOPT_MAXREDIRS which says in its description:
I think without some sort of epxlicit notice in that option stating that the type must be
long
that you'd get users that docurl_easy_setopt(curl, CURLOPT_MAXREDIRS, -1);
which is incorrect.I experimented with explicitly tacking on the
long
literal-suffixL
to all the numbers used to specify value in the options that takelong
. You can see that at jay@ca7c8da. The more I look at it the less I like it.I wonder though, assuming the type must be
long
and notint
or badness will happen, that maybe something different should be done, like for each option have a new sectionIMPORTANT
and say something like4673094
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.
On non-windows 64bit systems that will generally lead to badness, exactly as you say. I've tried to write that a long must be passed in all descriptions of numerical vararg options but I'm sure it can be emphasized better and as you say, showing just "-1" is fairly misleading or downright wrong. Although "-1" is of course not exactly stating if it is long or int.
As definitions are just numbers I've tried to not imply that they are integers or longs so that implementations can choose to use them however they want, it is only passing them as arguments to libcurl vararg functions that need to have them as longs.
(as a side-note I could mention that I believe this int/long confusion is among the worst design decisions I've tricked us into having...)
4673094
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.
What do you think about the new section idea? It would mean adding something like this to every single option:
4673094
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'd prefer to make it specific for long options, which then can make us use a more direct language. We rarely have a problem with the types of the other options. Or the curl_off_t options could get something similar to the long one but adjusted to that type?
4673094
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.
Alright, what do you think of this