mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: fix "now.tv_sec maybe used uninitialized" warnings
Fixes a number of warnings that look like this:
In file included from ../spa/include/spa/utils/result.h:37,
from ../spa/plugins/alsa/alsa-seq.c:35:
In function ‘set_timers’,
inlined from ‘do_reassign_follower’ at ../spa/plugins/alsa/alsa-seq.c:909:2:
../spa/include/spa/utils/defs.h:191:39: warning: ‘now.tv_sec’ may be used uninitialized [-Wmaybe-uninitialized]
191 | #define SPA_TIMESPEC_TO_NSEC(ts) ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)
| ~~~~^~~~~~~~
../spa/plugins/alsa/alsa-seq.c:840:28: note: in expansion of macro ‘SPA_TIMESPEC_TO_NSEC’
840 | state->next_time = SPA_TIMESPEC_TO_NSEC(&now);
| ^~~~~~~~~~~~~~~~~~~~
../spa/plugins/alsa/alsa-seq.c: In function ‘do_reassign_follower’:
../spa/plugins/alsa/alsa-seq.c:836:25: note: ‘now’ declared here
836 | struct timespec now;
| ^~~
The reason for these warnings is that spa_system_clock_gettime() may
fail if a version check fails, but the code in question didn't check for
the possible fail. If it failed, then execution would continue, and the
arguments that were passed to the macro will be used uninitialized.
Fix this by checking whether function succeeded.
This commit is contained in:
parent
252e798ece
commit
ed9560fb03
2 changed files with 9 additions and 3 deletions
|
|
@ -1471,7 +1471,8 @@ static void alsa_on_timeout_event(struct spa_source *source)
|
|||
if (SPA_UNLIKELY(spa_log_level_enabled(state->log, SPA_LOG_LEVEL_TRACE))) {
|
||||
struct timespec now;
|
||||
uint64_t nsec;
|
||||
spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now);
|
||||
if (spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now) < 0)
|
||||
return;
|
||||
nsec = SPA_TIMESPEC_TO_NSEC(&now);
|
||||
spa_log_trace_fp(state->log, NAME" %p: timeout %lu %lu %"PRIu64" %"PRIu64" %"PRIi64
|
||||
" %d %"PRIi64, state, delay, target, nsec, state->current_time,
|
||||
|
|
@ -1509,7 +1510,10 @@ static void reset_buffers(struct state *this)
|
|||
static int set_timers(struct state *state)
|
||||
{
|
||||
struct timespec now;
|
||||
spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now);
|
||||
int res;
|
||||
|
||||
if ((res = spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now)) < 0)
|
||||
return res;
|
||||
state->next_time = SPA_TIMESPEC_TO_NSEC(&now);
|
||||
|
||||
if (state->following) {
|
||||
|
|
|
|||
|
|
@ -834,8 +834,10 @@ static void reset_stream(struct seq_state *this, struct seq_stream *stream, bool
|
|||
static int set_timers(struct seq_state *state)
|
||||
{
|
||||
struct timespec now;
|
||||
int res;
|
||||
|
||||
spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now);
|
||||
if ((res = spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now)) < 0)
|
||||
return res;
|
||||
|
||||
state->next_time = SPA_TIMESPEC_TO_NSEC(&now);
|
||||
if (state->following) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue