-
Notifications
You must be signed in to change notification settings - Fork 155
GCC warnings #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GCC warnings #106
Conversation
warning: '%d' directive writing between 1 and 11 bytes into a region of size 9 [-Wformat-overflow=] note: '__builtin___sprintf_chk' output between 9 and 19 bytes into a destination of size 16 return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, __bos (__s), __fmt, __va_arg_pack ()); Make filename long enough for '/dev/lpt' + '-1234567890' + '\0'
…h to know the int value can only be two digits.
|
Nice! I compiled for win32/64 and see fall through warnings for following lines. I didn't try dos (my cross compiler not working). |
|
Not sure how I missed some of them. Surely GCC would have caught those ones too.. I'll have another look. The gfxlib code seems quite complex. If it is genuinely supposed to fall through, then the fix is obvious, Might also be worth reformatting the case a bit. fbc/src/gfxlib2/win32/gfx_win32.c Line 329 in 8271887
|
|
I've submitted a couple more changes - some warnings appeared the next time I did a clean make, some from your list didn't appear at all, so I looked through and changed them all myself. Hopefully I didn't miss any.. Looking at the win32 gfx code, I guess I can now say that WM_SIZE falls through to WM_SYSKEYDOWN (to handle their Maximize events), and WM_SYSKEYDOWN falls through to WM_KEYDOWN (to handle key events), but WM_SIZE will not fall through to WM_KEYDOWN. It might be that it can be refactored - the Otherwise the simplest solution is to put a comment in saying something like |
…lScreen - fix WM_SYSKEYDOWN message; it should fall through to WM_KEYDOWN|UP handler
|
Hopefully we've caught all the warnings now. I am committing this. Thanks both for taking the time to look at this. It's been helpful. |
This is my first commit for a while. Doing a PR seems like a nice way to go about this.
This fixes some compiler warnings I came across while making from Ubuntu 18.04 (64-bit).
Most are implicit
switch()fall-throughs, two aresprintf()buffer allocation warnings.Note that I've made one of the fall-throughs into a
goto, to match the other cases in that block. The fall-through worked because it was the last case in the block, but could have broken if another case were added. The compiler should be able to optimise it out anyway.The joystick
sprintf()warning was difficult to make a decision about, because the problem is GCC not understanding thatjcan only be two digits. I extended the buffer, but other approaches might involve changing the type ofj, using character manipulation or something to write the digits, or just ignoring the warning.With these changes, the rtlib and gfxlib compile without warnings in (my version of) Linux.