We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4999 - MSVC Static analysis: Incorrect alpha_value check in SDL_render.c
Summary: MSVC Static analysis: Incorrect alpha_value check in SDL_render.c
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.1
Hardware: x86 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-21 19:53 UTC by Cameron Gutman
Modified: 2020-02-23 08:58 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Gutman 2020-02-21 19:53:57 UTC
MSVC's static analysis found this one and it looks like a legitimate bug.

"Incorrect operator: mutual exclusion over || is always a non-zero constant.  Did you intend to use && instead?"

    /* If Palette contains alpha values, promotes to alpha format */
    if (fmt->palette) {
        for (i = 0; i < fmt->palette->ncolors; i++) {
            Uint8 alpha_value = fmt->palette->colors[i].a;
            if (alpha_value != 0 || alpha_value != SDL_ALPHA_OPAQUE) { <---- HERE
                needAlpha = SDL_TRUE;
                break;
            }
        }
    }


https://hg.libsdl.org/SDL/file/28fcb5ef7ff1/src/render/SDL_render.c#l1170
Comment 1 Sylvain 2020-02-23 08:58:44 UTC
Thanks good catch ! palette surface were then always promoted to alpha.
https://hg.libsdl.org/SDL/rev/c66d1c7700bd

(At the same time, I spotted another issue and re-open bug 4425)