audio: Fix static analysis concerns about a dead assignment.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 24 Jan 2017 10:09:29 -0500
changeset 1084632efb3bc4db5
parent 10845 c2b0d3d180f4
child 10847 425040bd82be
audio: Fix static analysis concerns about a dead assignment.
src/audio/SDL_audiocvt.c
     1.1 --- a/src/audio/SDL_audiocvt.c	Tue Jan 24 00:55:41 2017 -0500
     1.2 +++ b/src/audio/SDL_audiocvt.c	Tue Jan 24 10:09:29 2017 -0500
     1.3 @@ -1147,7 +1147,7 @@
     1.4  SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, const Uint32 _buflen)
     1.5  {
     1.6      int buflen = (int) _buflen;
     1.7 -    SDL_bool copied = SDL_FALSE;
     1.8 +    const void *origbuf = buf;
     1.9  
    1.10      /* !!! FIXME: several converters can take advantage of SIMD, but only
    1.11         !!! FIXME:  if the data is aligned to 16 bytes. EnsureStreamBufferSize()
    1.12 @@ -1173,7 +1173,7 @@
    1.13          if (workbuf == NULL) {
    1.14              return -1;  /* probably out of memory. */
    1.15          }
    1.16 -        copied = SDL_TRUE;
    1.17 +        SDL_assert(buf == origbuf);
    1.18          SDL_memcpy(workbuf, buf, buflen);
    1.19          stream->cvt_before_resampling.buf = workbuf;
    1.20          stream->cvt_before_resampling.len = buflen;
    1.21 @@ -1190,9 +1190,8 @@
    1.22          if (workbuf == NULL) {
    1.23              return -1;  /* probably out of memory. */
    1.24          }
    1.25 -        if (!copied) {
    1.26 +        if (buf == origbuf) {  /* copy if we haven't before. */
    1.27              SDL_memcpy(workbuf, buf, buflen);
    1.28 -            copied = SDL_TRUE;
    1.29          }
    1.30          buflen = stream->resampler_func(stream, workbuf, buflen, workbuf, workbuflen);
    1.31          buf = workbuf;
    1.32 @@ -1204,11 +1203,9 @@
    1.33          if (workbuf == NULL) {
    1.34              return -1;  /* probably out of memory. */
    1.35          }
    1.36 -        if (!copied) {
    1.37 +        if (buf == origbuf) {  /* copy if we haven't before. */
    1.38              SDL_memcpy(workbuf, buf, buflen);
    1.39 -            copied = SDL_TRUE;
    1.40          }
    1.41 -
    1.42          stream->cvt_after_resampling.buf = workbuf;
    1.43          stream->cvt_after_resampling.len = buflen;
    1.44          if (SDL_ConvertAudio(&stream->cvt_after_resampling) == -1) {