mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	iochannel: don't use variable length array in union
Clang didn't like the variable length array:
pulsecore/iochannel.c:358:17: error: fields must have a constant size:
'variable length array in structure' extension will never be supported
        uint8_t data[CMSG_SPACE(sizeof(int) * nfd)];
                ^
Commit 451d1d6762 introduced the variable length array in order to have
the correct value in msg_controllen. This patch reverts that commit and
uses a different way to achieve the same goal.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99458
			
			
This commit is contained in:
		
							parent
							
								
									0cb72beace
								
							
						
					
					
						commit
						18ec0fe53e
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -355,7 +355,7 @@ ssize_t pa_iochannel_write_with_fds(pa_iochannel*io, const void*data, size_t l,
 | 
				
			||||||
    struct iovec iov;
 | 
					    struct iovec iov;
 | 
				
			||||||
    union {
 | 
					    union {
 | 
				
			||||||
        struct cmsghdr hdr;
 | 
					        struct cmsghdr hdr;
 | 
				
			||||||
        uint8_t data[CMSG_SPACE(sizeof(int) * nfd)];
 | 
					        uint8_t data[CMSG_SPACE(sizeof(int) * MAX_ANCIL_DATA_FDS)];
 | 
				
			||||||
    } cmsg;
 | 
					    } cmsg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(io);
 | 
					    pa_assert(io);
 | 
				
			||||||
| 
						 | 
					@ -382,7 +382,13 @@ ssize_t pa_iochannel_write_with_fds(pa_iochannel*io, const void*data, size_t l,
 | 
				
			||||||
    mh.msg_iov = &iov;
 | 
					    mh.msg_iov = &iov;
 | 
				
			||||||
    mh.msg_iovlen = 1;
 | 
					    mh.msg_iovlen = 1;
 | 
				
			||||||
    mh.msg_control = &cmsg;
 | 
					    mh.msg_control = &cmsg;
 | 
				
			||||||
    mh.msg_controllen = sizeof(cmsg);
 | 
					
 | 
				
			||||||
 | 
					    /* If we followed the example on the cmsg man page, we'd use
 | 
				
			||||||
 | 
					     * sizeof(cmsg.data) here, but if nfd < MAX_ANCIL_DATA_FDS, then the data
 | 
				
			||||||
 | 
					     * buffer is larger than needed, and the kernel doesn't like it if we set
 | 
				
			||||||
 | 
					     * msg_controllen to a larger than necessary value. The commit message for
 | 
				
			||||||
 | 
					     * commit 451d1d6762 contains a longer explanation. */
 | 
				
			||||||
 | 
					    mh.msg_controllen = CMSG_SPACE(sizeof(int) * nfd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((r = sendmsg(io->ofd, &mh, MSG_NOSIGNAL)) >= 0) {
 | 
					    if ((r = sendmsg(io->ofd, &mh, MSG_NOSIGNAL)) >= 0) {
 | 
				
			||||||
        io->writable = io->hungup = false;
 | 
					        io->writable = io->hungup = false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue