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 4030

Summary: warning C4018: '<': signed/unsigned mismatch
Product: SDL_ttf Reporter: Steve Robinson <ssrobins>
Component: miscAssignee: 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

Description Steve Robinson 2018-01-08 00:35:57 UTC
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.
Comment 1 Sylvain 2018-10-26 10:19:06 UTC
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
Comment 2 Ozkan Sezer 2018-10-27 07:04:16 UTC
Sam, I won't mess with this one, it's for you.
Comment 3 Sam Lantinga 2018-10-28 21:20:54 UTC
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?
Comment 4 Sylvain 2018-10-29 10:41:52 UTC
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
Comment 5 Sylvain 2018-10-29 10:52:11 UTC
Created attachment 3410 [details]
patch v2

patch updated to the HEAD, with also showfont.c / glfont.c
Comment 6 Sam Lantinga 2018-10-30 03:08:23 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/41b93d8303d6