[vlc-devel] [PATCH] access/dtv + stream_filter/decomp: fix initialization of struct iovec

Filip Roséen filip at atch.se
Sun Feb 26 16:56:00 CET 2017


The order, and number, of data-members inside struct iovec is not
guaranteed according to the POSIX specification; as such these changes
make sure that we initialize what we expect to initialize by using
designated-initializers.

--

 - http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_uio.h.html
---
 modules/access/dtv/en50221.c   | 4 ++--
 modules/stream_filter/decomp.c | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/modules/access/dtv/en50221.c b/modules/access/dtv/en50221.c
index a31f4fae01..9976a2d273 100644
--- a/modules/access/dtv/en50221.c
+++ b/modules/access/dtv/en50221.c
@@ -244,8 +244,8 @@ static int TPDUSend( cam_t * p_cam, uint8_t i_slot, uint8_t i_tag,
     Dump( true, p_data, p - p_data );
 
     const struct iovec iov[2] = {
-        { p_data, p - p_data },
-        { (void *)p_content, i_length },
+        { .iov_base = p_data, .iov_len = p - p_data },
+        { .iov_base = (void *)p_content, .iov_len = i_length },
     };
 
     if ( writev( p_cam->fd, iov, 2 ) <= 0 )
diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c
index e3d9af3776..7e7b021c8a 100644
--- a/modules/stream_filter/decomp.c
+++ b/modules/stream_filter/decomp.c
@@ -150,7 +150,10 @@ static void *Thread (void *data)
                 j = write (fd, buf + i, len - i);
             else
             {
-                struct iovec iov = { buf + i, (len - i) & ~page_mask, };
+                struct iovec iov = {
+                    .iov_base = buf + i,
+                    .iov_len = (len - i) & ~page_mask };
+
                 j = vmsplice (fd, &iov, 1, SPLICE_F_GIFT);
             }
             if (j == -1 && errno == ENOSYS) /* vmsplice() not supported */
-- 
2.11.1



More information about the vlc-devel mailing list