xiph / xiph/opus

Clang's static code analysis flagged multiple warnings against the latest master branch

Open
#146 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.3k
Forks
808
PR merge metrics
No merged PRs in 30d

Description

silk/encode_pulses.c

2019-09-26T07:58:36.1361860Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/silk/encode_pulses.c:49:34: warning: The left operand of '+' is a garbage value
2019-09-26T07:58:36.1363248Z analyze-build: INFO:         sum = pulses_in[ 2 * k ] + pulses_in[ 2 * k + 1 ];
2019-09-26T07:58:36.1363930Z analyze-build: INFO:               ~~~~~~~~~~~~~~~~~~ ^
2019-09-26T07:58:36.1364767Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/silk/encode_pulses.c:125:43: warning: The left operand of '>>' is a garbage value
2019-09-26T07:58:36.1365486Z analyze-build: INFO:                     abs_pulses_ptr[ k ] = silk_RSHIFT( abs_pulses_ptr[ k ], 1 );
2019-09-26T07:58:36.1366396Z analyze-build: INFO:                                           ^            ~~~~~~~~~~~~~~~~~~~
2019-09-26T07:58:36.1367129Z analyze-build: INFO: ./silk/SigProc_FIX.h:511:45: note: expanded from macro 'silk_RSHIFT'
2019-09-26T07:58:36.1367861Z analyze-build: INFO: #define silk_RSHIFT(a, shift)               silk_RSHIFT32(a, shift)                         /* shift >= 0, shift < 32 */
2019-09-26T07:58:36.1368516Z analyze-build: INFO:                                             ^             ~
2019-09-26T07:58:36.1369168Z analyze-build: INFO: ./silk/SigProc_FIX.h:509:49: note: expanded from macro 'silk_RSHIFT32'
2019-09-26T07:58:36.1370765Z analyze-build: INFO: #define silk_RSHIFT32(a, shift)             ((a)>>(shift))                                  /* shift >= 0, shift < 32 */

src/opus_decoder.c

2019-09-26T07:58:44.7362538Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/src/opus_decoder.c:133:24: warning: Use of zero-allocated memory
2019-09-26T07:58:44.7363684Z analyze-build: INFO:    st->silk_dec_offset = align(sizeof(OpusDecoder));
2019-09-26T07:58:44.7364250Z analyze-build: INFO:                        ^

celt/vq.c

2019-09-26T07:58:49.7360810Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/vq.c:288:16: warning: The right operand of '+' is a garbage value
2019-09-26T07:58:49.7362199Z analyze-build: INFO:          Ryy = ADD16(yy, y[j]);
2019-09-26T07:58:49.7362865Z analyze-build: INFO:                ^         ~~~~
2019-09-26T07:58:49.7363397Z analyze-build: INFO: ./celt/arch.h:242:24: note: expanded from macro 'ADD16'
2019-09-26T07:58:49.7363886Z analyze-build: INFO: #define ADD16(a,b) ((a)+(b))
2019-09-26T07:58:49.7364362Z analyze-build: INFO:                        ^ ~

celt/celt_encoder.c

2019-09-26T07:59:46.6070802Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/celt_encoder.c:1067:17: warning: The left operand of '>' is a garbage value
2019-09-26T07:59:46.6072237Z analyze-build: INFO:          f[1] = MAX16(f[1], tmp);
2019-09-26T07:59:46.6072613Z analyze-build: INFO:                 ^     ~~~~
2019-09-26T07:59:46.6072942Z analyze-build: INFO: ./celt/arch.h:98:25: note: expanded from macro 'MAX16'
2019-09-26T07:59:46.6073362Z analyze-build: INFO: #define MAX16(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 16-bit value.   */
2019-09-26T07:59:46.6073642Z analyze-build: INFO:                      ~  ^
2019-09-26T07:59:46.6073875Z analyze-build: INFO: 1 warning generated.

celt/pitch.c

2019-09-26T07:59:47.5977150Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/pitch.c:100:20: warning: The left operand of '*' is a garbage value
2019-09-26T07:59:47.5979058Z analyze-build: INFO:       Syy += SHR32(MULT16_16(y[i+len],y[i+len]),yshift) - SHR32(MULT16_16(y[i],y[i]),yshift);
2019-09-26T07:59:47.5979837Z analyze-build: INFO:                    ^         ~~~~~~~~
2019-09-26T07:59:47.5980512Z analyze-build: INFO: ./celt/arch.h:249:44: note: expanded from macro 'MULT16_16'
2019-09-26T07:59:47.5981166Z analyze-build: INFO: #define MULT16_16(a,b)     ((opus_val32)(a)*(opus_val32)(b))
2019-09-26T07:59:47.5982221Z analyze-build: INFO:                                          ~ ^
2019-09-26T07:59:47.5982925Z analyze-build: INFO: ./celt/arch.h:226:25: note: expanded from macro 'SHR32'
2019-09-26T07:59:47.5983488Z analyze-build: INFO: #define SHR32(a,shift) (a)
2019-09-26T07:59:47.5984507Z analyze-build: INFO:                         ^
2019-09-26T07:59:47.5985165Z analyze-build: INFO: 1 warning generated.

celt/bands.c

2019-09-26T07:59:57.6343981Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/bands.c:622:31: warning: Array access (from variable 'X') results in a null pointer dereference
2019-09-26T07:59:57.6345161Z analyze-build: INFO:             tmp[j*stride+i] = X[ordery[i]*N0+j];
2019-09-26T07:59:57.6345777Z analyze-build: INFO:                               ^~~~~~~~~~~~~~~~~
2019-09-26T07:59:57.6346492Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/bands.c:628:4: warning: Null pointer passed as an argument to a 'nonnull' parameter
2019-09-26T07:59:57.6347265Z analyze-build: INFO:    OPUS_COPY(X, tmp, N);
2019-09-26T07:59:57.6347825Z analyze-build: INFO:    ^~~~~~~~~~~~~~~~~~~~
2019-09-26T07:59:57.6348403Z analyze-build: INFO: ./celt/os_support.h:72:33: note: expanded from macro 'OPUS_COPY'
2019-09-26T07:59:57.6349570Z analyze-build: INFO: #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
2019-09-26T07:59:57.6350285Z analyze-build: INFO:                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-09-26T07:59:57.6351469Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/bands.c:640:17: warning: Array access (from variable 'X') results in a null pointer dereference
2019-09-26T07:59:57.6352564Z analyze-build: INFO:          tmp1 = MULT16_16(QCONST16(.70710678f,15), X[stride*2*j+i]);
2019-09-26T07:59:57.6353515Z analyze-build: INFO:                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-09-26T07:59:57.6354183Z analyze-build: INFO: ./celt/arch.h:249:57: note: expanded from macro 'MULT16_16'
2019-09-26T07:59:57.6355145Z analyze-build: INFO: #define MULT16_16(a,b)     ((opus_val32)(a)*(opus_val32)(b))
2019-09-26T07:59:57.6355780Z analyze-build: INFO:                                                         ^~~
2019-09-26T07:59:57.6356580Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/bands.c:932:15: warning: Array access (from variable 'x') results in a null pointer dereference
2019-09-26T07:59:57.6357302Z analyze-build: INFO:          x[0] = sign ? -NORM_SCALING : NORM_SCALING;
2019-09-26T07:59:57.6357909Z analyze-build: INFO:          ~    ^
2019-09-26T07:59:57.6358953Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/bands.c:1083:27: warning: Array access (from variable 'X') results in a null pointer dereference
2019-09-26T07:59:57.6359737Z analyze-build: INFO:                      X[j] = (celt_norm)((opus_int32)ctx->seed>>20);
2019-09-26T07:59:57.6360343Z analyze-build: INFO:                      ~    ^
2019-09-26T07:59:57.6361143Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/bands.c:1227:30: warning: Array access (from variable 'X') results in a null pointer dereference
2019-09-26T07:59:57.6361824Z analyze-build: INFO:             lowband_out[j] = MULT16_16_Q15(n,X[j]);
2019-09-26T07:59:57.6362587Z analyze-build: INFO:                              ^~~~~~~~~~~~~~~~~~~~~
2019-09-26T07:59:57.6363834Z analyze-build: INFO: ./celt/arch.h:264:37: note: expanded from macro 'MULT16_16_Q15'
2019-09-26T07:59:57.6364425Z analyze-build: INFO: #define MULT16_16_Q15(a,b)     ((a)*(b))
2019-09-26T07:59:57.6364869Z analyze-build: INFO:                                     ^~~
2019-09-26T07:59:57.6365269Z analyze-build: INFO: 6 warnings generated.

celt/celt_lpc.c

2019-09-26T08:00:16.2110667Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/celt_lpc.c:270:14: warning: The right operand of '*' is a garbage value
2019-09-26T08:00:16.2111378Z analyze-build: INFO:          d = MAC16_16(d, xptr[i], xptr[i-k]);
2019-09-26T08:00:16.2111902Z analyze-build: INFO:              ^                    ~~~~~~~~~
2019-09-26T08:00:16.2112876Z analyze-build: INFO: ./celt/arch.h:250:49: note: expanded from macro 'MAC16_16'
2019-09-26T08:00:16.2114255Z analyze-build: INFO: #define MAC16_16(c,a,b)     ((c)+(opus_val32)(a)*(opus_val32)(b))
2019-09-26T08:00:16.2114623Z analyze-build: INFO:                                                 ^             ~
2019-09-26T08:00:16.2114879Z analyze-build: INFO: 1 warning generated.

celt/quant_bands.c

2019-09-26T08:00:30.7756914Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/celt/quant_bands.c:483:69: warning: The right operand of '+' is a garbage value due to array index out of bounds
2019-09-26T08:00:30.7758146Z analyze-build: INFO:          tmp = PSHR32(MULT16_16(coef,oldEBands[i+c*m->nbEBands]),8) + prev[c] + SHL32(q,7);
2019-09-26T08:00:30.7758735Z analyze-build: INFO:                                                                     ^ ~~~~~~~
2019-09-26T08:00:30.7759643Z analyze-build: INFO: 1 warning generated.

silk/LPC_inv_pred_gain.c

2019-09-26T08:00:43.8995952Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/silk/LPC_inv_pred_gain.c:83:21: warning: The result of the right shift is undefined because the right operand is negative
2019-09-26T08:00:43.9001476Z analyze-build: INFO:             tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( silk_SUB_SAT32(tmp1,
2019-09-26T08:00:43.9002361Z analyze-build: INFO:                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-09-26T08:00:43.9003080Z analyze-build: INFO: ./silk/SigProc_FIX.h:532:92: note: expanded from macro 'silk_RSHIFT_ROUND64'
2019-09-26T08:00:43.9004000Z analyze-build: INFO: #define silk_RSHIFT_ROUND64(a, shift)       ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
2019-09-26T08:00:43.9005147Z analyze-build: INFO:                                                                                        ~~~~^~~~~~~~~~~~~~~~
2019-09-26T08:00:43.9006228Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/silk/LPC_inv_pred_gain.c:89:21: warning: The result of the right shift is undefined because the right operand is negative
2019-09-26T08:00:43.9007070Z analyze-build: INFO:             tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( silk_SUB_SAT32(tmp2,
2019-09-26T08:00:43.9007675Z analyze-build: INFO:                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-09-26T08:00:43.9008283Z analyze-build: INFO: ./silk/SigProc_FIX.h:532:92: note: expanded from macro 'silk_RSHIFT_ROUND64'
2019-09-26T08:00:43.9009543Z analyze-build: INFO: #define silk_RSHIFT_ROUND64(a, shift)       ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
2019-09-26T08:00:43.9010661Z analyze-build: INFO:                                                                                        ~~~~^~~~~~~~~~~~~~~~
2019-09-26T08:00:43.9011318Z analyze-build: INFO: 2 warnings generated.

silk/stereo_LR_to_MS.c

2019-09-26T08:00:53.0597880Z analyze-build: INFO: /home/runner/work/dosbox-staging/dosbox-staging/src/libs/decoders/internal/opus/silk/stereo_LR_to_MS.c:77:34: warning: Declared variable-length array (VLA) has negative size
2019-09-26T08:00:53.0599285Z analyze-build: INFO:     ALLOC( LP_mid, frame_length, opus_int16 );
2019-09-26T08:00:53.0599993Z analyze-build: INFO:     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
2019-09-26T08:00:53.0600993Z analyze-build: INFO: ./celt/stack_alloc.h:94:32: note: expanded from macro 'ALLOC'
2019-09-26T08:00:53.0601637Z analyze-build: INFO: #define ALLOC(var, size, type) type var[size]
2019-09-26T08:00:53.0602309Z analyze-build: INFO:                                ^~~~~~~~ ~~~~

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the listed files under src/libs/decoders/internal/opus, especially silk/encode_pulses.c, src/opus_decoder.c, celt/bands.c, celt/celt_encoder.c, celt/pitch.c, and celt/celt_lpc.c. Run Clang static analysis on the latest master and inspect each reported warning, including the referenced macros in silk/SigProc_FIX.h, celt/arch.h, and celt/os_support.h. Done means the reported warnings are resolved or demonstrably addressed without introducing codec regressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.