[vlc-devel] [PATCH v2] access_output: udp: fix conversion from uint8_t* on Windows

Alexandre Janniaux ajanni at videolabs.io
Fri Mar 27 17:30:50 CET 2020


Hi,

If we don't want to fix these warnings, we might want to locally
and specifically disable them.

Keeping them around is more harmful (because noisy) than being
there for nothing.

Regards,
--
Alexandre Janniaux
Videolabs

On Fri, Mar 27, 2020 at 06:09:20PM +0200, Rémi Denis-Courmont wrote:
> Le perjantaina 27. maaliskuuta 2020, 18.00.45 EET Alexandre Janniaux a écrit :
> > Hi,
> >
> > On Fri, Mar 27, 2020 at 05:39:18PM +0200, Rémi Denis-Courmont wrote:
> > > Le perjantaina 27. maaliskuuta 2020, 17.10.49 EET Alexandre Janniaux a
> écrit :
> > > > Like discussed on the mailing list, casting to char* would be incorrect
> > >
> > > You have a uint8_t * here. You can only convert it to unsigned char * (1)
> > > or keep it as is.
> >
> > No I can cast to (void*) without aliasing issues, as far as I know.
>
> You can, but the function will have to cast back to unsigned char * before
> dereference. The pointer can only be dereferenced as uint8_t * or
> unsigned char *.
>
> My point is that there's only two reasonable types for untyped binary data in
> C. The implicit convenient one is void *, and the explicit inconvenient one is
> unsigned char *. Anything else is a bug in the function prototype (and likely
> the implementation).
>
> > > Casting it to void * to mute pointer type warnings is something that we
> > > have consistently rejected, as it essentially amounts to hiding bugs.
> >
> > I agree, it's a much better argument, but the other workarounds I can
> > think of so far are:
> >
> > + wrap read() in a macro on Windows to use the correct type, which is
> >   awful, can lead to misleading warnings depending on includes and is
> >   more or less the same.
> >
> > + wrap read in a function and apply the correct fix for Windows here
> >   which is better but could non-intuitive. Adding warnings on usage of
> >   read/recv/write/send without going to the wrapper could help though.
> >
> > + rename the function in Microsoft headers with defines, and wrap the
> >   symbol to ensure we use the same prototype everywhere, but it could
> >   stop working if it is declared with parenthesis in Microsoft headers
> >   and could break even more things.
>
> Do nothing as we have (not) done for 20 years.
>
> Denis and I warned about platform bugs as one of the reasons against using -
> Werror. This is but an example.
>
> --
> Реми Дёни-Курмон
> http://www.remlab.net/
>
>
>
> _______________________________________________
> 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