On date Thursday 2011-09-08 14:31:41 +0200, Diego Biurrun encoded:
> ---
>  libavutil/fifo.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/fifo.c b/libavutil/fifo.c
> index 5774d33..75a0439 100644
> --- a/libavutil/fifo.c
> +++ b/libavutil/fifo.c
> @@ -145,8 +145,7 @@ int main(void)
>      /* peek at FIFO */
>      n = av_fifo_size(fifo)/sizeof(int);
>      for (i = -n+1; i < n; i++) {
> -        int *v = (int *)av_fifo_peek2(fifo, i*sizeof(int));
> -        printf("%d: %d\n", i, *v);
> +        printf("%d: %d\n", i, *av_fifo_peek2(fifo, i * sizeof(int)));

This one should be safer:

printf("%d: %d\n", i, *((int *)av_fifo_peek2(fifo, i*sizeof(int))));

that is you cast from (void *) -> (int *), and *then* dereference.

Otherwise it should be equivalent to:
(int)(*((void *)av_fifo_peek2(fifo, i*sizeof(int))))

which may or may not be correct depending on the
architecture/compiler, and employs void * dereference which is
undefined (maybe I'm wrong but better to be explicit with such tricky
stuff).
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to