Re: [PATCH] fix TLS error flagged by gcc-5.2.1

Jerry James <[email protected]> Mon, 7 Dec 2015 21:55:18 -0700
Newsgroups gmane.emacs.xemacs.patches
Message-ID <CAHCOHQ=qt3FjjcKcXTL4O8i3wJvtmf8d297ssp5N=qRS6RyNjw@mail.gmail.com>
Hi Jeff,

Thanks for the patch, but ...

On Fri, Nov 27, 2015 at 8:01 AM, Jeff Sparkes <[email protected]> wrote:
> I required this fix to compile with --with-tls=no on Ubuntu 15.10.
> Gcc 5.2.1 is a bit stricter about casts.

I just tried building with Fedora Rawhide, which also has gcc 5.2.1,
configured --with-tls=no, and got no errors.  Furthermore, ...

> diff --git a/src/tls.h b/src/tls.h
> --- a/src/tls.h
> +++ b/src/tls.h
> @@ -82,14 +82,14 @@
>  #define TLS_SETUP_SOCK 1
>  #define tls_open(x,y) ({                                               \
>        signal_error (Qtls_error, "TLS support unavailable", Qnil);      \
> -      NULL; })
> -#define tls_negotiate(x,y,z) NULL
> +      (int *)NULL; })
> +#define tls_negotiate(x,y,z) (int *)NULL
>  #define make_tls_input_stream(x) ({                                    \
>        signal_error (Qtls_error, "TLS support unavailable", Qnil);      \
> -      NULL; })
> +      (int *)NULL; })
>  #define make_tls_output_stream(x) ({                                   \
>        signal_error (Qtls_error, "TLS support unavailable", Qnil);      \
> -      NULL; })
> +      (int *)NULL; })
>  #define tls_get_fd(x)          -1
>  #define tls_read(w,x,y,z)      -1
>  #define tls_write(w,x,y,z)     -1

... this doesn't even make sense.  NULL is type void *, so it is
implicitly castable to any pointer type, whether it be int *, char *,
or struct some_imaginary_struct *.  Can you show the error you are
seeing, please, along with the compile flags you are using?  I'd like
to understand what is going on before changing any code.  Thanks,
-- 
Jerry James
http://www.jamezone.org/