[vlc-devel] [PATCH] configure: check socklen_t as int first

Steve Lhomme robux4 at ycbcr.xyz
Wed Mar 18 13:00:54 CET 2020


On 2020-02-17 9:19, KO Myung-Hun wrote:
> OS/2 socket APIs use int not unsigned int in place of socklen_t. As
> a result, compilation is stopped at function call requiring socklen_t *
> because of type mismatch between int * and unsigned int *.
> ---
>   configure.ac | 18 ++++++++++++++++--
>   1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 7741ddca55..16eee78456 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -759,8 +759,22 @@ ac_cv_type_socklen_t,
>   #endif]], [[socklen_t len; len = 0;]])],
>   ac_cv_type_socklen_t=yes,
>   ac_cv_type_socklen_t=no)])
> -AS_IF([test "$ac_cv_type_socklen_t" = no],
> - [AC_DEFINE(socklen_t, unsigned int)])
> +AS_IF([test "$ac_cv_type_socklen_t" = no], [
> +  VLC_SAVE_FLAGS
> +  CFLAGS="-Wpointer-sign -Werror"

This seems specific to your compiler, we may end up having a compilation 
error because of those flags, even if an 'unsigned int' is what we 
should use.

If your "compilation is stopped at function call requiring socklen_t *" 
then it's probably using flags to trigger that error. If they are set 
before this test of getpeername() it should have the same error.

You should probably test that getpeername() or whatever call is OK with 
unsigned int before using it. In fact you probably want to test that and 
default to int as done now.

Also if your API does have socklen_t but is not detected properly, it's 
probably better to detect it correctly.

> +  AC_COMPILE_IFELSE([
> +    AC_LANG_PROGRAM([[
> +#include <sys/types.h>
> +#ifdef _WIN32
> +# include <winsock2.h>
> +# include <ws2tcpip.h>
> +#else
> +# include <sys/socket.h>
> +#endif
> +]], [[getpeername(0, 0, (int *)0);]])],
> +    AC_DEFINE(socklen_t, int), AC_DEFINE(socklen_t, unsigned int))
> +  VLC_RESTORE_FLAGS
> +])
>   
>   dnl Check for struct sockaddr_storage
>   AH_TEMPLATE(sockaddr_storage, [Define to `sockaddr' if <sys/socket.h> does not define.]) dnl ` (fix VIM syntax highlight
> -- 
> 2.22.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list