Task #193

Fix current compiler warnings

Added by IR4T4 over 6 years ago. Updated over 5 years ago.

Status:Fixed% Done:

100%

Priority:NormalSpent time:-
Assignee:IR4T4
Category:General
Target version:2.71rc2
OS:Linux Arch:

Description

Clang (-Wall)

etlegacy/src/renderer/tr_bsp.c:322:12: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
        shaderNum = LittleLong(shaderNum);
        ~~~~~~~~~ ^            ~~~~~~~~~

etlegacy/src/game/g_character.c:119:36: warning: 'memset' call operates on objects of type 'animModelInfo_t' while the size is based on a different type 'animModelInfo_t *'
      [-Wsizeof-pointer-memaccess]
                memset(*animModelInfo, 0, sizeof(*animModelInfo));
                       ~~~~~~~~~~~~~~            ^~~~~~~~~~~~~~
etlegacy/src/game/g_character.c:119:36: note: did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?
                memset(*animModelInfo, 0, sizeof(*animModelInfo));
                                                 ^~~~~~~~~~~~~~

etlegacy/src/game/g_lua.c:34:59: warning: attribute declaration must precede definition [-Wignored-attributes]
void QDECL G_Lua_Printf(const char *fmt, ...) _attribute((format(printf, 1, 2)));
                                                          ^
etlegacy/src/game/bg_public.h:47:37: note: expanded from macro '_attribute'
#define _attribute(x) __attribute__(x)
                                    ^
etlegacy/src/game/g_lua.c:21:12: note: previous definition is here
void QDECL G_Lua_Printf(const char *fmt, ...)
           ^

Windows:

Warning    5129    warning C4701: potentially uninitialized local variable 'tr' used    c:\etlegacy\src\cgame\cg_effects.c    1097    1    cgame_mp_x86
Warning    9451    warning C4701: potentially uninitialized local variable 'r' used    c:\etlegacy\src\qcommon\vm.c    695    1    etl
Warning    9897    warning C4701: potentially uninitialized local variable 'compareip' used    c:\etlegacy\src\qcommon\net_ip.c    986    1    etl
Warning    9898    warning C4701: potentially uninitialized local variable 'comparemask' used    c:\etlegacy\src\qcommon\net_ip.c    986    1    etl
Warning    9899    warning C4701: potentially uninitialized local variable 'compareadr' used    c:\etlegacy\src\qcommon\net_ip.c    986    1    etl
Warning    9900    warning C4701: potentially uninitialized local variable 'addrsize' used    c:\etlegacy\src\qcommon\net_ip.c    984    1    etl
Warning    13301    warning C4701: potentially uninitialized local variable 'fov_x' used    c:\etlegacy\src\cgame\cg_view.c    1091    1    cgame_mp_x86
Warning    13780    warning C4701: potentially uninitialized local variable 'sound' used    c:\etlegacy\src\cgame\cg_sound.c    350    1    cgame_mp_x86
Warning    14477    warning C4701: potentially uninitialized local variable 'cmodel' used    c:\etlegacy\src\cgame\cg_predict.c    546    1    cgame_mp_x86
Warning    17221    warning C4701: potentially uninitialized local variable 'to' used    c:\etlegacy\src\client\cl_main.c    4437    1    etl
Warning    17222    warning C4701: potentially uninitialized local variable 'max' used    c:\etlegacy\src\client\cl_main.c    4741    1    etl
Warning    32759    warning C4701: potentially uninitialized local variable 'r' used    c:\etlegacy\src\qcommon\vm.c    695    1    etlded
Warning    33205    warning C4701: potentially uninitialized local variable 'compareip' used    c:\etlegacy\src\qcommon\net_ip.c    986    1    etlded
Warning    33206    warning C4701: potentially uninitialized local variable 'comparemask' used    c:\etlegacy\src\qcommon\net_ip.c    986    1    etlded
Warning    33207    warning C4701: potentially uninitialized local variable 'compareadr' used    c:\etlegacy\src\qcommon\net_ip.c    986    1    etlded
Warning    33208    warning C4701: potentially uninitialized local variable 'addrsize' used    c:\etlegacy\src\qcommon\net_ip.c    984    1    etlded

Full list is here:
http://wklej.org/id/948276/

Associated revisions

Revision 11e97e8d
Added by deki over 6 years ago

misc: fix some msvc warnings, refs #193

Revision 44b81d9e
Added by IR4T4 over 6 years ago

UI: unused function UI_GetIndexFromSelection removed (updateSPMenu) refs
#50 refs #193

Revision 6569999f
Added by deki over 6 years ago

misc: fix some signedness mismatch warnings, refs #193

Revision e92b5008
Added by deki over 6 years ago

misc: fix signedness warnings, refs #193

Revision 17679b31
Added by IR4T4 over 6 years ago

misc: warning fixes refs #193

Revision c36790c0
Added by IR4T4 over 6 years ago

misc: warning fixes refs #193

Revision a113521e
Added by Radegast over 6 years ago

misc: silence warnings coming from third party includes, refs #193

Revision 0548ed7e
Added by Radegast over 6 years ago

misc: fixed duplicate static declaration with clang, refs #193

Revision c5c1522f
Added by IR4T4 over 6 years ago

misc: rework of some compiler flags refs #193 refs #188

Revision bde044c6
Added by IR4T4 over 6 years ago

misc: do compiler flags for all OS refs #193 refs #188

Revision e7c50b2d
Added by IR4T4 over 6 years ago

misc: exclude win for *nix optimization/debug gcc flags refs #193

Revision e3f4cd7c
Added by IR4T4 about 6 years ago

game: clang warning fix refs #193 (implicit conversion from enumeration
types)

Revision 3328a2a8
Added by IR4T4 about 6 years ago

cgame: warning fix refs #193

Revision 02c0a866
Added by IR4T4 about 6 years ago

generic: warning fixes refs #193

Revision 8dfb1626
Added by IR4T4 about 6 years ago

generic: warning fixes refs #193 #refs 243

Revision 37372354
Added by IR4T4 about 6 years ago

game: warning fix refs #193

Revision 93a5d45f
Added by IR4T4 about 6 years ago

linux: warning fix refs #193

Revision a3172125
Added by Radegast almost 6 years ago

misc: fixed a couple of Clang warnings, refs #193

Revision b7a1095a
Added by Radegast almost 6 years ago

misc: fixed clang’s "unsigned enum expression < 0 always true" warnings, refs #193

Revision 13b7ddcb
Added by Jan Šimek almost 6 years ago

generic: Windows build optimizations, warning fixes, refs #193

Revision 8b51ba01
Added by Radegast over 5 years ago

Merge pull request #62 from kkthx/misc

misc: visual studio warnings fix, refs #193

History

#1 Updated by IR4T4 over 6 years ago

  • Category set to General
  • Target version set to 2.71rc1

#2 Updated by IR4T4 over 6 years ago

  • Subject changed from Fix current warnings to Fix current compiler warnings

#3 Updated by IR4T4 over 6 years ago

  • Description updated (diff)

#4 Updated by deki over 6 years ago

GCC also knows the flag -Wextra, which enables more warnings (http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html), that are not shown with -Wall.

#5 Updated by IR4T4 over 6 years ago

  • Description updated (diff)
  • Assignee set to deki
  • % Done changed from 0 to 30

#6 Updated by Radegast over 6 years ago

  • Description updated (diff)

Vorbis warnings fixed in 0548ed7eff5c7ee16bb687b8e3033cb2d59dfad2

#9 Updated by IR4T4 over 6 years ago

  • Target version changed from 2.71rc1 to 2.71rc2

#10 Updated by IR4T4 about 6 years ago

  • Assignee changed from deki to IR4T4
  • % Done changed from 30 to 50

The following warning came up lately I assume it’s caused by the renderer2 changes. All other warnings are fixed for Linux (gcc 4.4.5 ,-Wall=Debug)

src/sdl/sdl_glimp.c: In function ‘GLimp_SetMode’:                           
src/sdl/sdl_glimp.c:650: warning: statement with no effect
src/sdl/sdl_glimp.c: At top level:
src/sdl/sdl_glimp.c:98: warning: ‘opengl_context’ defined but not used

#11 Updated by IR4T4 about 6 years ago

  • % Done changed from 50 to 80

#12 Updated by IR4T4 almost 6 years ago

  • Target version changed from 2.71rc2 to 2.78

#13 Updated by Radegast almost 6 years ago

Another type of warning I get when compiling with Clang:

src/cgame/cg_popupmessages.c:311:11: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
        if (type < 0 || type >= PM_NUM_TYPES)
            ~~~~ ^ ~

src/game/bg_stats.c:102:16: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
        if (iWeaponID < 0 || iWeaponID <= WP_NUM_WEAPONS)
            ~~~~~~~~~ ^ ~

From what I read, enum sightedness differs between compilers and to overcome this, we could just assign the first member to zero to make the enum unsigned. Source: http://stackoverflow.com/questions/159034/are-c-enums-signed-or-unsigned

#14 Updated by IR4T4 almost 6 years ago

This has been already done in many typedef enums. Just fix it.

#15 Updated by Radegast almost 6 years ago

  • Description updated (diff)

ok, done. I’ve updated the ticket description with the current clang warnings.

#16 Updated by IR4T4 almost 6 years ago

Some warnings to fix on Windows:

#17 Updated by Jacker almost 6 years ago

Do we want to touch/"fix" that as it is not our code?

#18 Updated by Radegast almost 6 years ago

Jacker wrote:

Do we want to touch/"fix" that as it is not our code?

tinygettext will become our code, because there are no packages for it and the last commit is 2 years old, so it is not actively developed anymore. I will move it to the main repository. Touching any other 3rd party library would be pointless as the changes would be overwritten after the next update.

#19 Updated by IR4T4 over 5 years ago

  • Category changed from General to 9
  • Target version changed from 2.78 to 2.71rc2
  • % Done changed from 80 to 100

I’ll close this now. There aren’t warnings on Linux debug/release builds anymore (at least for me, except renderer2) and the above info is obsolete.
Feel free to open new platform specific issues ...

#20 Updated by IR4T4 over 5 years ago

  • Status changed from New to Fixed

#21 Updated by Radegast over 5 years ago

  • OS set to Linux

Also available in: Atom PDF