mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	raop-sink: Fix compiler warnings
There were three maybe-uninitialized warnings when building with
Autotools (for some reason I don't see these with Meson):
modules/raop/raop-sink.c: In function ‘thread_func’:
modules/raop/raop-sink.c:543:16: warning: ‘intvl’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             if (intvl < now + u->block_usec) {
                ^
In file included from ./pulsecore/macro.h:270,
                 from ./pulsecore/cpu-x86.h:25,
                 from ./pulsecore/cpu.h:23,
                 from ./pulsecore/core.h:26,
                 from modules/raop/raop-sink.c:48:
./pulsecore/log.h:129:28: warning: ‘check_timing_count’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 #define pa_log_warn(...)   pa_log_level_meta(PA_LOG_WARN,   __FILE__, __LINE__, __func__, __VA_ARGS__)
                            ^~~~~~~~~~~~~~~~~
modules/raop/raop-sink.c:404:14: note: ‘check_timing_count’ was declared here
     uint32_t check_timing_count;
              ^~~~~~~~~~~~~~~~~~
modules/raop/raop-sink.c:500:27: warning: ‘last_timing’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                 pa_usec_t since = now - last_timing;
                           ^~~~~
I moved the intvl variable initialization out of the for loop, because
it looked like the variable value is supposed to be remembered between
the iterations. I don't know if the variable declaration (without
initialization) in the beginning of the loop caused the compiler to
touch the variable between iterations, probably not, but I'm pretty sure
that's undefined behaviour.
Other than that maybe-undefined behaviour, these compiler warnings may
be false positives, since the variables are initialized when u->first is
true.
I initialized the three variables in to the same value as what is used
when resetting them when u->first is true. I didn't test these changes,
but they look safe to me.
			
			
This commit is contained in:
		
							parent
							
								
									ee6caebbb0
								
							
						
					
					
						commit
						fb3e4bb54c
					
				
					 1 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -400,8 +400,9 @@ static void sink_set_mute_cb(pa_sink *s) {
 | 
			
		|||
static void thread_func(void *userdata) {
 | 
			
		||||
    struct userdata *u = userdata;
 | 
			
		||||
    size_t offset = 0;
 | 
			
		||||
    pa_usec_t last_timing;
 | 
			
		||||
    uint32_t check_timing_count;
 | 
			
		||||
    pa_usec_t last_timing = 0;
 | 
			
		||||
    uint32_t check_timing_count = 1;
 | 
			
		||||
    pa_usec_t intvl = 0;
 | 
			
		||||
 | 
			
		||||
    pa_assert(u);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -413,7 +414,7 @@ static void thread_func(void *userdata) {
 | 
			
		|||
    for (;;) {
 | 
			
		||||
        struct pollfd *pollfd = NULL;
 | 
			
		||||
        unsigned int i, nbfds = 0;
 | 
			
		||||
        pa_usec_t now, estimated, intvl;
 | 
			
		||||
        pa_usec_t now, estimated;
 | 
			
		||||
        uint64_t position;
 | 
			
		||||
        size_t index;
 | 
			
		||||
        int ret;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue