audio: Code defensively to placate static analyzers, don't disabling warnings.
parent
bdd47f7770
commit
12b371679f
|
@ -1811,7 +1811,8 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
||||||
for (int i = 0; i < num_streams; i++) {
|
for (int i = 0; i < num_streams; i++) {
|
||||||
SDL_AudioStream *stream = streams[i];
|
SDL_AudioStream *stream = streams[i];
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
retval = SDL_SetError("Stream #%d is NULL", i);
|
SDL_SetError("Stream #%d is NULL", i);
|
||||||
|
retval = -1; // to pacify the static analyzer, that doesn't realize SDL_SetError() always returns -1.
|
||||||
} else {
|
} else {
|
||||||
SDL_LockMutex(stream->lock);
|
SDL_LockMutex(stream->lock);
|
||||||
SDL_assert((stream->bound_device == NULL) == ((stream->prev_binding == NULL) || (stream->next_binding == NULL)));
|
SDL_assert((stream->bound_device == NULL) == ((stream->prev_binding == NULL) || (stream->next_binding == NULL)));
|
||||||
|
@ -1839,12 +1840,8 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
||||||
// Now that everything is verified, chain everything together.
|
// Now that everything is verified, chain everything together.
|
||||||
const SDL_bool iscapture = device->iscapture;
|
const SDL_bool iscapture = device->iscapture;
|
||||||
for (int i = 0; i < num_streams; i++) {
|
for (int i = 0; i < num_streams; i++) {
|
||||||
#ifdef _MSC_VER /* Visual Studio analyzer can't tell that streams[i] isn't NULL if retval is 0 */
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable : 28182)
|
|
||||||
#endif
|
|
||||||
SDL_AudioStream *stream = streams[i];
|
SDL_AudioStream *stream = streams[i];
|
||||||
|
if (stream) { // shouldn't be NULL, but just in case...
|
||||||
stream->bound_device = logdev;
|
stream->bound_device = logdev;
|
||||||
stream->prev_binding = NULL;
|
stream->prev_binding = NULL;
|
||||||
stream->next_binding = logdev->bound_streams;
|
stream->next_binding = logdev->bound_streams;
|
||||||
|
@ -1861,9 +1858,7 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockMutex(stream->lock);
|
SDL_UnlockMutex(stream->lock);
|
||||||
#ifdef _MSC_VER
|
}
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue