AquariaOSE / Aquaria

Aquaria open source, forked from icculus.org due to inactivity. Has many enhancements compared to the original version.
http://bit-blot.com/aquaria
GNU General Public License v2.0
297 stars 82 forks source link

Large number of warnings with Clang 3.7.0 #23

Closed jbeich closed 7 years ago

jbeich commented 9 years ago

As of OSE-v1.002 on

$ c++ -v
FreeBSD clang version 3.7.0 (trunk 242221) 20150808
Target: x86_64-unknown-freebsd11.0
Thread model: posix

with default *FLAGS that don't have any -Wfoo e.g.,

$ touch Aquaria/Avatar.cpp
$ ninja -v
[1/2] /usr/bin/c++   -DAQUARIA_BUILD_CONSOLE=1 -DAQUARIA_BUILD_SCENEEDITOR=1 -DBBGE_BUILD_ACHIEVEMENTS_INTERNAL=1 -DBBGE_BUILD_FMOD_OPENAL_BRIDGE=1 -DBBGE_BUILD_FRAMEBUFFER=1 -DBBGE_BUILD_OPENGL=1 -DBBGE_BUILD_OPENGL_DYNAMIC=1 -DBBGE_BUILD_SDL=1 -DBBGE_BUILD_SHADERS=1 -DBBGE_BUILD_UNIX=1 -DBBGE_BUILD_VFS=1 -DBBGE_SKIP_CONFIG_HEADERS=1 -DBBGE_USE_GLM=1 -DGL_GLEXT_LEGACY=1 -DHAVE_PUTENV=1 -DHAVE_STRCASECMP -DLUA_USE_ULONGJMP=1 -DNDEBUG -DTIXML_USE_STL=1 -DVFS_ENABLE_C_API=1 -O3 -DNDEBUG -IBBGE -IBBGE/GL -IExternalLibs/glpng/zlib -IExternalLibs/glpng/png -IAquaria -IExternalLibs/FTGL/include -IExternalLibs/freetype2/include -IExternalLibs/lua-5.1.4/src -IExternalLibs/libogg-1.3.0/include -IExternalLibs/libvorbis-1.3.3/include -I/usr/local/include/SDL -I/usr/local/include -I/usr/local/include/AL -IExternalLibs -IExternalLibs/ttvfs -IExternalLibs/ttvfs_zip -IExternalLibs/ttvfs_cfileapi -MMD -MT CMakeFiles/aquaria.dir/Aquaria/Avatar.cpp.o -MF CMakeFiles/aquaria.dir/Aquaria/Avatar.cpp.o.d -o CMakeFiles/aquaria.dir/Aquaria/Avatar.cpp.o -c Aquaria/Avatar.cpp
^C
ExternalLibs/ttvfs_zip/miniz.c:4020:5: warning: expression result unused [-Wunused-value]
    pFilename; return MZ_FALSE;
    ^~~~~~~~~
ExternalLibs/ttvfs_zip/VFSFileZip.cpp:146:11: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
    if(sz < 0)
       ~~ ^ ~
In file included from ExternalLibs/ttvfs/VFSTools.cpp:18:
/usr/include/sys/dir.h:39:2: warning: "The information in this file should be obtained from <dirent.h>" [-W#warnings]
#warning "The information in this file should be obtained from <dirent.h>"
 ^
/usr/include/sys/dir.h:40:2: warning: "and is provided solely (and temporarily) for backward compatibility." [-W#warnings]
#warning "and is provided solely (and temporarily) for backward compatibility."
 ^
Aquaria/AquariaMenuItem.cpp:631:10: warning: enumeration value 'INPUTSET_NONE' not handled in switch [-Wswitch]
                switch(inputSetType)
                       ^
Aquaria/CollideEntity.cpp:57:10: warning: enumeration value 'BOUNCE_NONE' not handled in switch [-Wswitch]
        switch (bounceType)
                ^
Aquaria/Avatar.cpp:391:12: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
        channel = BBGE_AUDIO_NOCHANNEL;
                  ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:559:13: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                channel = BBGE_AUDIO_NOCHANNEL;
                          ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:663:13: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                channel = BBGE_AUDIO_NOCHANNEL;
                          ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:918:9: warning: 9 enumeration values not handled in switch: 'FORM_NONE', 'FORM_NORMAL', 'FORM_BEAST'... [-Wswitch]
        switch(dsq->continuity.form)
               ^
Aquaria/Avatar.cpp:1327:10: warning: enumeration values 'EAT_NONE', 'EAT_DEFAULT', and 'EAT_MAX' not handled in switch [-Wswitch]
                switch(et)
                       ^
Aquaria/Avatar.cpp:1646:10: warning: enumeration values 'FORM_NONE' and 'FORM_MAX' not handled in switch [-Wswitch]
                switch(form)
                       ^
Aquaria/Avatar.cpp:2467:9: warning: enumeration values 'FORM_NONE', 'FORM_NORMAL', and 'FORM_MAX' not handled in switch [-Wswitch]
        switch(dsq->continuity.form)
               ^
Aquaria/Avatar.cpp:3146:9: warning: 8 enumeration values not handled in switch: 'FORM_NONE', 'FORM_NORMAL', 'FORM_BEAST'... [-Wswitch]
        switch(dsq->continuity.form)
               ^
Aquaria/Avatar.cpp:3249:9: warning: 5 enumeration values not handled in switch: 'FORM_NONE', 'FORM_NORMAL', 'FORM_SPIRIT'... [-Wswitch]
        switch(dsq->continuity.form)
               ^
Aquaria/Avatar.cpp:3278:24: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                        dsq->loops.charge = BBGE_AUDIO_NOCHANNEL;
                                            ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:3431:24: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                        dsq->loops.charge = BBGE_AUDIO_NOCHANNEL;
                                            ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:3670:21: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                dsq->loops.trip = BBGE_AUDIO_NOCHANNEL;
                                  ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:3689:21: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                dsq->loops.trip = BBGE_AUDIO_NOCHANNEL;
                                  ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:3802:22: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
        dsq->loops.shield = BBGE_AUDIO_NOCHANNEL;
                            ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:3807:22: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
        dsq->loops.charge = BBGE_AUDIO_NOCHANNEL;
                            ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:4194:23: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                dsq->loops.shield = BBGE_AUDIO_NOCHANNEL;
                                    ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:4199:24: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                dsq->loops.current = BBGE_AUDIO_NOCHANNEL;
                                     ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:4874:10: warning: enumeration values 'AURA_NONE', 'AURA_THING', and 'AURA_HEAL' not handled in switch [-Wswitch]
                switch(activeAura)
                       ^
Aquaria/Avatar.cpp:4937:23: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                dsq->loops.shield = BBGE_AUDIO_NOCHANNEL;
                                    ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:5003:10: warning: 7 enumeration values not handled in switch: 'FORM_NONE', 'FORM_NORMAL', 'FORM_BEAST'... [-Wswitch]
        switch (dsq->continuity.form)
                ^
Aquaria/Avatar.cpp:5174:21: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                dsq->loops.roll = BBGE_AUDIO_NOCHANNEL;
                                  ^~~~~~~~~~~~~~~~~~~~
Aquaria/Avatar.cpp:6178:28: warning: implicit conversion from 'double' to 'int' changes value from 1.5 to 1 [-Wliteral-conversion]
                                        chargeLevelAttained = 1.5;
                                                            ~ ^~~
Aquaria/Avatar.cpp:6172:12: warning: 6 enumeration values not handled in switch: 'FORM_NONE', 'FORM_NORMAL', 'FORM_BEAST'... [-Wswitch]
                        switch (dsq->continuity.form)
                                ^
Aquaria/Avatar.cpp:6696:25: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                        dsq->loops.current = BBGE_AUDIO_NOCHANNEL;
                                             ^~~~~~~~~~~~~~~~~~~~
Aquaria/Continuity.cpp:510:9: warning: enumeration values 'IET_NONE', 'IET_RANDOM', and 'IET_MAX' not handled in switch [-Wswitch]
        switch(useType)
               ^
Aquaria/Continuity.cpp:1231:9: warning: enumeration values 'FORM_NONE' and 'FORM_MAX' not handled in switch [-Wswitch]
        switch(form)
               ^
Aquaria/Continuity.cpp:1517:10: warning: 4 enumeration values not handled in switch: 'SONG_NONE', 'SONG_SONGDOOR2', 'SONG_ANIMA'... [-Wswitch]
                switch((SongType)num)
                       ^
Aquaria/DSQ.cpp:1923:9: warning: enumeration value 'INPUT_KEYBOARD' not handled in switch [-Wswitch]
        switch(inputMode)
               ^
Aquaria/DSQ.cpp:1937:9: warning: enumeration value 'INPUT_KEYBOARD' not handled in switch [-Wswitch]
        switch(inputMode)
               ^
Aquaria/DSQ.cpp:4453:11: warning: enumeration value 'INPUT_KEYBOARD' not handled in switch [-Wswitch]
                        switch(dsq->inputMode)
                               ^
Aquaria/MiniMapRender.cpp:585:13: warning: 13 enumeration values not handled in switch: 'PATH_NONE', 'PATH_CURRENT', 'PATH_STEAM'... [-Wswitch]
                                        switch(p->pathType)
                                               ^
Aquaria/SceneEditor.cpp:3013:9: warning: enumeration values 'ET_SELECTENTITY' and 'ET_MAX' not handled in switch [-Wswitch]
        switch(editType)
               ^
Aquaria/SceneEditor.cpp:3163:11: warning: enumeration values 'ET_PATHS', 'ET_SELECTENTITY', and 'ET_MAX' not handled in switch [-Wswitch]
                switch (editType)
                        ^
Aquaria/SceneEditor.cpp:3248:11: warning: enumeration values 'ES_ROTATING' and 'ES_MAX' not handled in switch [-Wswitch]
                        switch(state)
                               ^
Aquaria/SceneEditor.cpp:3299:11: warning: enumeration values 'ES_SELECTING', 'ES_SCALING', and 'ES_MAX' not handled in switch [-Wswitch]
                        switch(state)
                               ^
Aquaria/SceneEditor.cpp:3389:12: warning: incrementing expression of type bool is deprecated [-Wdeprecated-increment-bool]
                                        noSide++;
                                        ~~~~~~^
Aquaria/SceneEditor.cpp:3326:11: warning: enumeration value 'ES_MAX' not handled in switch [-Wswitch]
                        switch(state)
                               ^
Aquaria/Game.cpp:1208:18: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
        dsq->loops.bg = BBGE_AUDIO_NOCHANNEL;
                        ^~~~~~~~~~~~~~~~~~~~
Aquaria/Game.cpp:1209:19: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
        dsq->loops.bg2 = BBGE_AUDIO_NOCHANNEL;
                         ^~~~~~~~~~~~~~~~~~~~
Aquaria/Game.cpp:5774:20: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                        dsq->loops.bg = BBGE_AUDIO_NOCHANNEL;
                                        ^~~~~~~~~~~~~~~~~~~~
Aquaria/Game.cpp:6876:18: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
        dsq->loops.bg = BBGE_AUDIO_NOCHANNEL;
                        ^~~~~~~~~~~~~~~~~~~~
Aquaria/Game.cpp:8280:11: warning: 9 enumeration values not handled in switch: 'FORM_NONE', 'FORM_NORMAL', 'FORM_ENERGY'... [-Wswitch]
                switch (dsq->continuity.form)
                        ^
Aquaria/Game.cpp:9989:22: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                                dsq->loops.bg2 = BBGE_AUDIO_NOCHANNEL;
                                                 ^~~~~~~~~~~~~~~~~~~~
Aquaria/Game.cpp:10008:21: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                        dsq->loops.bg2 = BBGE_AUDIO_NOCHANNEL;
                                         ^~~~~~~~~~~~~~~~~~~~
Aquaria/SFXLoops.cpp:25:55: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
        bg = bg2 = roll = shield = charge = current = trip = BBGE_AUDIO_NOCHANNEL;
                                                             ^~~~~~~~~~~~~~~~~~~~
Aquaria/SFXLoops.cpp:44:11: warning: expression which evaluates to zero treated as a null pointer constant of type 'void *' [-Wnon-literal-null-conversion]
                *loop = BBGE_AUDIO_NOCHANNEL;
                        ^~~~~~~~~~~~~~~~~~~~
BBGE/Base.cpp:56:9: warning: 6 enumeration values not handled in switch: 'DIR_NONE', 'DIR_UPLEFT', 'DIR_UPRIGHT'... [-Wswitch]
        switch(dir)
               ^
BBGE/Base.cpp:76:9: warning: 6 enumeration values not handled in switch: 'DIR_NONE', 'DIR_UPLEFT', 'DIR_UPRIGHT'... [-Wswitch]
        switch(dir)
               ^
BBGE/Base.cpp:97:9: warning: 6 enumeration values not handled in switch: 'DIR_NONE', 'DIR_UPLEFT', 'DIR_UPRIGHT'... [-Wswitch]
        switch(dir)
               ^
BBGE/Base.cpp:682:17: warning: address of array 'file->d_name' will always evaluate to 'true' [-Wpointer-bool-conversion]
                    if (file->d_name && strlen(file->d_name) > 4)
                        ~~~~~~^~~~~~ ~~
BBGE/Collision.cpp:93:10: warning: enumeration values 'NONE' and 'TRIANGLE' not handled in switch [-Wswitch]
                switch(collisionShape.getType())
                       ^
BBGE/Collision.cpp:89:10: warning: 4 enumeration values not handled in switch: 'NONE', 'AABB', 'TOP_HALF_CIRCLE'... [-Wswitch]
        switch (getType())
                ^
BBGE/Collision.cpp:208:9: warning: enumeration values 'NONE', 'TOP_HALF_CIRCLE', and 'TRIANGLE' not handled in switch [-Wswitch]
        switch(getType())
               ^
BBGE/Collision.cpp:393:10: warning: enumeration values 'NONE', 'TOP_HALF_CIRCLE', and 'TRIANGLE' not handled in switch [-Wswitch]
        switch (this->getType())
                ^
BBGE/Effects.cpp:82:11: warning: enumeration values 'FTX_NONE' and 'FXT_MAX' not handled in switch [-Wswitch]
                        switch(type)
                               ^
In file included from BBGE/RenderObject.cpp:29:
In file included from ExternalLibs/glm/glm.hpp:19:
ExternalLibs/glm/core/setup.hpp:138:16: warning: LLVM [-W#pragma-messages]
#       pragma message("LLVM")
               ^
In file included from BBGE/RenderObject.cpp:29:
In file included from ExternalLibs/glm/glm.hpp:72:
In file included from ExternalLibs/glm/./core/func_integer.hpp:159:
ExternalLibs/glm/core/func_integer.inl:91:96: warning: operator '<<' has lower precedence than '-'; '-' will be evaluated first [-Wshift-op-parentheses]
                                return genUType(detail::highp_int_t(1) << detail::highp_int_t(32) + detail::highp_int_t(x) - detail::highp_int_t(y));
                                                                       ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ExternalLibs/glm/core/func_integer.inl:91:96: note: place parentheses around the '-' expression to silence this warning
                                return genUType(detail::highp_int_t(1) << detail::highp_int_t(32) + detail::highp_int_t(x) - detail::highp_int_t(y));
                                                                                                                           ^
                                                                          (                                                                        )
BBGE/SoundManager.cpp:446:9: warning: enumeration values 'SFX_NONE' and 'SFX_MAX' not handled in switch [-Wswitch]
        switch(effect){
               ^
BBGE/SoundManager.cpp:1561:9: warning: expression which evaluates to zero treated as a null pointer constant of type 'Buffer' (aka 'void *') [-Wnon-literal-null-conversion]
        return BBGE_AUDIO_NOCHANNEL;
               ^~~~~~~~~~~~~~~~~~~~
BBGE/Texture.cpp:279:41: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
        if ((pos != std::string::npos) && (pos >= 0))
                                           ~~~ ^  ~
BBGE/SkeletalSprite.cpp:366:9: warning: enumeration values 'AC_SEGS_START' and 'AC_SEGS_STOP' not handled in switch [-Wswitch]
        switch(command)
               ^
ExternalLibs/glpng/zlib/inflate.c:1475:61: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
    if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
                                                        ~~~ ^
In file included from ExternalLibs/freetype2/src/cff/cff.c:24:
ExternalLibs/freetype2/src/cff/cffload.c:1258:38: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
    top->underline_position  = -100L << 16;
                               ~~~~~ ^
ExternalLibs/lua-5.1.4/src/lauxlib.c:577:61: warning: while loop has empty body [-Wempty-body]
   while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
                                                            ^
ExternalLibs/lua-5.1.4/src/lauxlib.c:577:61: note: put the semicolon on a separate line to silence this warning
CMakeFiles/aquaria.dir/ExternalLibs/lua-5.1.4/src/loslib.c.o: In function `os_tmpname':
ExternalLibs/lua-5.1.4/src/loslib.c:(.text+0x857): warning: warning: tmpnam() possibly used unsafely; consider using mkstemp()
fgenesis commented 9 years ago

I know, I won't even touch those, because i'm scared of breaking something -- wouldn't be the first time D: The code works, so i usually just look away when compiling with clang on linux + osx. If you feel the need for fixing the warnings then go ahead, but i'd consider this a pretty fruitless effort looking at the overall code quality...

A similar funny example: First this: https://hg.icculus.org/icculus/lugaru/rev/4ab0f3cbd5e9 And soon after, this: https://hg.icculus.org/icculus/lugaru/rev/ac3f429a2830

If it's okay for you to leave it at that, please close, otherwise feel free to argue and throw tomatoes or pointy things at me. (Or make a pull request that fixes the warnings)

EDIT: For a laugh, enable -Wall -pedantic. So much nope.

Cat-Ion commented 7 years ago

Almost all warnings in the aquaria code itself are gone in the experimental branch. When enabling internal libs (except for SDL and OpenAL, as there's no prebuilt version of those), I still get some 150 warnings, most of which are in freetype2. For those I'd suggest putting newer versions of the libs into the repo. The game works with my system libraries, so that shouldn't be a problem. If the newer versions still have warnings, we can then get those fixed upstream.