[vlc-devel] [PATCH 1/2] chroma: copy: do not use an empty structure if SSE2 is not supported

Thomas Guillem thomas at gllm.fr
Fri May 3 09:06:33 CEST 2019


I agree with Steve.

On Fri, May 3, 2019, at 08:05, Steve Lhomme wrote:
> On 5/2/2019 4:56 PM, Rémi Denis-Courmont wrote:
> > Le torstaina 2. toukokuuta 2019, 12.36.29 EEST Steve Lhomme a écrit :
> >> Structures with no field should not be used, it's Undefined Behavior:
> >> https://stackoverflow.com/questions/3849334/sizeof-empty-structure-is-0-in-c
> >> -and-1-in-c-why ---
> >>   modules/video_chroma/copy.h | 2 ++
> >>   1 file changed, 2 insertions(+)
> >>
> >> diff --git a/modules/video_chroma/copy.h b/modules/video_chroma/copy.h
> >> index 6c463226f1..b06dc680cc 100644
> >> --- a/modules/video_chroma/copy.h
> >> +++ b/modules/video_chroma/copy.h
> >> @@ -29,6 +29,8 @@ typedef struct {
> >>   # ifdef CAN_COMPILE_SSE2
> >>       uint8_t *buffer;
> >>       size_t  size;
> >> +# else
> >> +    char dummy;
> >>   # endif
> >>   } copy_cache_t;
> > Better to move the whole structure at all under the ifdef, IMO.
> 
> That means all the copy_cache_t API calls also have to put around that 
> ifdef. And meaning if we support it on more architecture (ARM for 
> example) all the code has to be updated accordingly. IMO this simple fix 
> is safer for now.
> _______________________________________________
> 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