mackron / dr_libs

Audio decoding libraries for C/C++, each in a single source file.
Other
1.24k stars 205 forks source link

dr_wav: logic inference, flagged by PVS Studio #153

Closed kcgen closed 3 years ago

kcgen commented 3 years ago

2020-11-10_11-32

Full report attached (extract, enter the 'general' directory, open index.html:

pvs-analysis-report.zip

kcgen commented 3 years ago

I'm not sure if this is correct, but PVS's insights can sometimes point out order-of-operations changes that might read more naturally.

For example, maybe sampleCountFromFactChunk could be moved after the seek (unless its some kind of global variable that's used by the seek function).

mackron commented 3 years ago

I'm setting this one to Will Not Fix. I just don't understand why on Earth PVS would be suggesting that sampleCountFromFactChunk may want to be used inside drwav__seek_forward() - that makes no sense at all. In any case, I'm happy with the logic flow and I don't think there's anything needing to be changed.

kcgen commented 3 years ago

Thanks for the quick assessment!

kcgen commented 3 years ago

For those who might also hit this in PVS, the following suppression can be used:

        {
            "CodeCurrent": 1849716353,
            "CodeNext": 11359373,
            "CodePrev": 2663124891,
            "ErrorCode": "V1051",
            "FileName": "dr_wav.h",
            "Message": "Consider checking for misprints. It's possible that the 'sampleCountFromFactChunk' should be used inside 'drwav__seek_forward' function."
        },