mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	pulsecore/shm: Remove shm_marker struct packing for pa_atomic_t fields
Taking addresses of fields in a packed struct are not guaranteed to be
aligned, resulting in warnings such as:
    ../src/pulsecore/shm.c: In function 'sharedmem_create':
    ../src/pulsecore/shm.c:198:25: error: taking address of packed member of 'struct shm_marker' may result in an unaligned pointer value [-Werror=address-of-packed-member]
      198 |         pa_atomic_store(&marker->pid, (int) getpid());
          |                         ^~~~~~~~~~~~
The struct already has its fields and types laid out in such a way that
the desired packing (without padding) is guaranteed - enforce this with
a `static_assert` to get rid of the unaligned pointer warning.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/653>
			
			
This commit is contained in:
		
							parent
							
								
									6e1ba7179c
								
							
						
					
					
						commit
						add6e71e4c
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -91,7 +91,10 @@ struct shm_marker {
 | 
				
			||||||
    uint64_t _reserved2;
 | 
					    uint64_t _reserved2;
 | 
				
			||||||
    uint64_t _reserved3;
 | 
					    uint64_t _reserved3;
 | 
				
			||||||
    uint64_t _reserved4;
 | 
					    uint64_t _reserved4;
 | 
				
			||||||
} PA_GCC_PACKED;
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Ensure struct is appropriately packed
 | 
				
			||||||
 | 
					static_assert(sizeof(struct shm_marker) == 8 * 5, "`struct shm_marker` is not tightly packed");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline size_t shm_marker_size(pa_mem_type_t type) {
 | 
					static inline size_t shm_marker_size(pa_mem_type_t type) {
 | 
				
			||||||
    if (type == PA_MEM_TYPE_SHARED_POSIX)
 | 
					    if (type == PA_MEM_TYPE_SHARED_POSIX)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue