| Summary: | warning C4018: '<': signed/unsigned mismatch | ||
|---|---|---|---|
| Product: | SDL_ttf | Reporter: | Steve Robinson <ssrobins> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | sezeroz, sylvain.becker |
| Version: | 2.0.14 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 10 | ||
| Attachments: |
patch
list of warnings before/after patch v2 |
||
Created attachment 3400 [details]
patch
Fix a few warnings
- unsigned/signed in
- bad-function-cast ((int)SDL_ceil)
- double/float SDL_ceil vs SDL_ceilf
- use pixmap pointer current as in other functions
- comment out unused function
- cast int8* to int32* (break alignment)
- lost of "const" during cast char*
- use of SDL_min/max to make code readable
- freetype index are unsigned int
Sam, I won't mess with this one, it's for you. Sylvain, I already fixed the warnings, can you look at the latest code and see what other parts of your patch are important? I assume nothing in here is critical for 2.0.15 release? Created attachment 3409 [details]
list of warnings before/after
Hi Sam, nothing critical! just warnings reported by clang/gcc.
I am attaching the list I got before/after the patch (that I have updaded with HEAD also with fix for showfont.c and glfont.c).
the thing we could care is not a warning, but for the code to be more read-able:
- the use of pointer "current = &glyph->pixmap / bitmap" as in other function, as in all ttf render function.
- the use of SDL_min/max
Created attachment 3410 [details]
patch v2
patch updated to the HEAD, with also showfont.c / glfont.c
Patch added, thanks! https://hg.libsdl.org/SDL/rev/41b93d8303d6 |
I build SDL_ttf.c on Visual Studio 2017 on Windows 10 and I get several several instances of the following build warning: warning C4018: '<': signed/unsigned mismatch It stems from having a mix of unsigned ints and ints in for loops. The 'easy' fix is to go from this: for (row = 0; row < glyph->pixmap.rows; ++row) { To this: for (row = 0; row < (int)glyph->pixmap.rows; ++row) { The deeper fix would be looking into the possibility of using only one or the other and avoid casting. This is only a minor impact to me. I'm trying to get as much of my codebase to treat warnings as errors so it's easy to see new issues that arise when upgrading libs, upgrading compilers, or changing my code.