Skip to content

Conversation

@schmonz
Copy link
Member

@schmonz schmonz commented Nov 20, 2020

The clang warning message says "passing 'int *' to parameter of type
'socklen_t *' (aka 'unsigned int *') converts between pointers to
integer types with different sign". Indeed, the passed values are from
sizeof(). Make them unsigned.

@schmonz schmonz added the build label Nov 20, 2020
@schmonz schmonz added this to the 1.09 milestone Nov 20, 2020
@schmonz schmonz force-pushed the schmonz-Wpointer-sign branch from 83d99b1 to 0da4bfa Compare November 20, 2020 10:30
@schmonz schmonz linked an issue Nov 20, 2020 that may be closed by this pull request
Copy link
Member

@DerDakon DerDakon left a comment

Choose a reason for hiding this comment

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

From accept(2):

The socklen_t type
In the original BSD sockets implementation (and on other older systems) the third argument of accept() was declared as an int *. A POSIX.1g draft standard wanted to change it into a size_t *C; later POSIX standards and glibc 2.x have socklen_t * .

So, this was once right, but now the new type will cause less warning on recent (i.e. from this century) systems. This may then cause warnings on ancient systems, but who cares.

Copy link

@josuah josuah left a comment

Choose a reason for hiding this comment

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

Maybe socklen_t instead of unsigned int? Not a huge difference, and better than plain int anyway.

[EDIT: multiple independent PoV converge]

The clang warning message says "passing 'int *' to parameter of type
'socklen_t *' (aka 'unsigned int *') converts between pointers to
integer types with different sign". Indeed, the passed values are from
sizeof(). Make them unsigned.
@schmonz schmonz force-pushed the schmonz-Wpointer-sign branch from 0da4bfa to 9421d40 Compare November 27, 2020 23:59
@schmonz schmonz merged commit ac7172c into master Nov 28, 2020
@schmonz schmonz deleted the schmonz-Wpointer-sign branch November 28, 2020 00:10
@DerDakon
Copy link
Member

While I would use socklen_t in any of my code I fear that this is exactly that type of ancient compatibility issues that may actually break this for someone. When we eventually go and break everything we can break that, too ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default to -Wall (but not -Werror)

5 participants