Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminated warnings in Visual Studio 2019. #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Jun 12, 2022

  1. Eliminated warning in Visual Studio 2019.

    The Microsoft C/C++ compiler warned about possibly
    writing too much memory in lines like this:
    
        memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
    
    Although the code is correct, it confuses the compiler
    into thinking more memory is being zeroed out than
    intended. scratch.grbuf[0] holds only half as many
    bytes as scratch.grbuf, but the code intends to
    zero out the entire array, not just the first half.
    
    Replaced with identical code that eliminates
    the warning:
    
        memset(scratch.grbuf, 0, sizeof(scratch.grbuf));
    
    This is also easier to understand and verify as correct.
    cosinekitty committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    2bf3d73 View commit details
    Browse the repository at this point in the history
  2. Fixed compiler warning in L3_stereo_process.

    The Visual Studio 2019 C/C++ compiler reported
    a warning that the following array accesses in
    L3_stereo_process could go out of bounds:
    
        kl = g_pan[2*ipos];
        kr = g_pan[2*ipos + 1];
    
    The compiler apparently believes that the
    value of the expression `HDR_TEST_MPEG1(hdr)`
    could change its value when evaluated more than once,
    even though it is clear from the code that the header
    data is constant. The compiler's false theory results
    in a perceived risk of reading outside the array
    bounds of `g_pan`.
    
    By explicitly evaluating `HDR_TEST_MPEG1(hdr)`
    exactly once and holding its value in a local
    variable, the warning disappears.
    cosinekitty committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    0b9300f View commit details
    Browse the repository at this point in the history