[vlc-devel] [PATCH] misc/interrupt: use designated initializers for struct iovec

Rémi Denis-Courmont remi at remlab.net
Sun Jul 17 09:44:03 CEST 2016


Le keskiviikkona 13. heinäkuuta 2016, 19.35.16 EEST Filip Roséen a écrit :
> Given that POSIX does not guarantee the order (nor the number) of the
> data-members within "struct iovec", we should either use designated
> initializers, or direct member-access, to initialize struct iovec.{iov_base,
> iov_len}.
> 
> As designated-initialiazers are used in other parts of src/misc/interrupt.c,
> this patch does the same.
> 
> --
> 
>  * http://pubs.opengroup.org/onlinepubs/007904975/toc.htm
> 
> ---
>  src/misc/interrupt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/misc/interrupt.c b/src/misc/interrupt.c
> index eddaca6..5699e81 100644
> --- a/src/misc/interrupt.c
> +++ b/src/misc/interrupt.c
> @@ -514,7 +514,7 @@ ssize_t vlc_writev_i11e(int fd, const struct iovec *iov,
> int count) */
>  ssize_t vlc_read_i11e(int fd, void *buf, size_t count)
>  {
> -    struct iovec iov = { buf, count };
> +    struct iovec iov = { .iov_base = buf, .iov_len = count };
>      return vlc_readv_i11e(fd, &iov, 1);
>  }
> 
> @@ -527,7 +527,7 @@ ssize_t vlc_read_i11e(int fd, void *buf, size_t count)
>   */
>  ssize_t vlc_write_i11e(int fd, const void *buf, size_t count)
>  {
> -    struct iovec iov = { (void *)buf, count };
> +    struct iovec iov = { .iov_base = buf, .iov_len = count };
>      return vlc_writev_i11e(fd, &iov, 1);
>  }

This introduces a compiler warning.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list