GithubHelp home page GithubHelp logo

Comments (3)

kcgen avatar kcgen commented on August 29, 2024

This was caught in a recent Coverity scan. Happy to help run more and confirm / trial any fixes, as you see fit 👍

from nuked-opl3.

kmar avatar kmar commented on August 29, 2024

well, coverity obviously doesn't understand that if ((channum % 9) < 2) will only allow max channum of 10 to actually pass the condition so no out of bounds index will ever happen (13 < 18)

this is the problem with static analyzers - they're unreliable and the typical large amount of false positives makes one waste time coding around them rather than doing something productive - which is why I rely solely on sanitizers these days. they're reliable and free

from nuked-opl3.

kcgen avatar kcgen commented on August 29, 2024

Thanks @kmar,

Indeed - the code as a whole is good.

Coverity's flagged the if (channum % 9) < 3) logic with the "local" flag, which will allow any batch of channums through (even those beyond 18). It hangs together because the for loop's limit prevents pushing larger number through this logic.

The % 9 logic is relative but the channel array size is absolute.

I believe Coverity would be happy either way:

  • make both relative: if the channel array would grow in proportion to this loop bounds (both become relative and scale).
  • make both absolute: convert (channum % 9) < 3) to use absolutes just like the array size:
    if (channum <= 2 || (channum >= 9 && channum <= 11)) or without magic numbers:
    if (is_channel_4op(channum) || is_channel_4op2(channum))

from nuked-opl3.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.