Closed bubbleguuum closed 4 months ago
There are also these 2 warnings that I did not address yet:
src/engine/net_client.c:1279:19: error: implicit conversion from enumeration type 'net_connstate_t' to different enumeration type 'net_clientstate_t' [-Werror,-Wenum-conversion]
1279 | client_state = NET_CONN_STATE_DISCONNECTED;
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
it looks to me that the line should be client_connection.state = NET_CONN_STATE_DISCONNECTED;
//////////
src/engine/p_inter.c:1153:38: error: & has lower precedence than >; > will be evaluated first [-Werror,-Wparentheses]
1153 | || (source->flags ^ target->flags) & p_disable_monster_infighting.value > 0))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As it is written, code above is equivalent to (source->flags ^ target->flags) & (p_disable_monster_infighting.value > 0))
Is it correct or should it be ((source->flags ^ target->flags) & p_disable_monster_infighting.value) > 0
?
It´s ((source->flags ^ target->flags) & p_disable_monster_infighting.value) > 0
Thanks, fixed the test.
@Wolf3s
I do not think that the 'fixed wrong test' patch is correct as gcc
now gives an error (not a warning!) and compilation fails on the line:
src/engine/p_inter.c: In function ‘P_DamageMobj’:
src/engine/p_inter.c:1153:53: error: invalid operands to binary & (have ‘int’ and ‘float’)
1153 | || ((source->flags ^ target->flags) & p_disable_monster_infighting.value) > 0))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| int float
so &
is applied between int
and float
and it does not look right. Interestingly, clang
compile this without error.
Would not be surprised the correct statement is || ((source->flags ^ target->flags) && p_disable_monster_infighting.value > 0)
@Wolf3s
I do not think that the 'fixed wrong test' patch is correct as
gcc
now gives an error (not a warning!) and compilation fails on the line:src/engine/p_inter.c: In function ‘P_DamageMobj’: src/engine/p_inter.c:1153:53: error: invalid operands to binary & (have ‘int’ and ‘float’) 1153 | || ((source->flags ^ target->flags) & p_disable_monster_infighting.value) > 0)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int float
so
&
is applied betweenint
andfloat
and it does not look right. Interestingly,clang
compile this without error.Would not be surprised the correct statement is
|| ((source->flags ^ target->flags) && p_disable_monster_infighting.value > 0)
use and(&&) and should work.
When compiling with gcc
and LTO enabled (-flto
) which might be in default CFLAGS
when compiling for some distros, there are these warnings at link time with 3 functions with prototypes not matching. This look a bit suspicious:
src/engine/p_map.c:710:6: warning: type of ‘P_ZMovement’ does not match original declaration [-Wlto-type-mismatch]
710 | void P_ZMovement(mobj_t* mo, int checkmissile);
| ^
src/engine/p_mobj.c:297:6: note: type mismatch in parameter 2
297 | void P_ZMovement(mobj_t* mo) {
| ^
src/engine/p_mobj.c:297:6: note: type ‘void’ should match type ‘int’
src/engine/p_mobj.c:297:6: note: ‘P_ZMovement’ was previously declared here
src/engine/g_game.c:71:13: warning: type of ‘M_SaveGame’ does not match original declaration [-Wlto-type-mismatch]
71 | extern void M_SaveGame(void);
| ^
src/engine/m_menu.c:3202:6: note: type mismatch in parameter 1
3202 | void M_SaveGame(int choice) {
| ^
src/engine/m_menu.c:3202:6: note: type ‘int’ should match type ‘void’
src/engine/m_menu.c:3202:6: note: ‘M_SaveGame’ was previously declared here
src/engine/g_game.c:72:13: warning: type of ‘M_LoadGame’ does not match original declaration [-Wlto-type-mismatch]
72 | extern void M_LoadGame(void);
| ^
src/engine/m_menu.c:3301:6: note: type mismatch in parameter 1
3301 | void M_LoadGame(int choice) {
| ^
src/engine/m_menu.c:3301:6: note: type ‘int’ should match type ‘void’
src/engine/m_menu.c:3301:6: note: ‘M_LoadGame’ was previously declared here
When compiling with
gcc
and LTO enabled (-flto
) which might be in defaultCFLAGS
when compiling for some distros, there are these warnings at link time with 3 functions with prototypes not matching. This look a bit suspicious:src/engine/p_map.c:710:6: warning: type of ‘P_ZMovement’ does not match original declaration [-Wlto-type-mismatch] 710 | void P_ZMovement(mobj_t* mo, int checkmissile); | ^ src/engine/p_mobj.c:297:6: note: type mismatch in parameter 2 297 | void P_ZMovement(mobj_t* mo) { | ^ src/engine/p_mobj.c:297:6: note: type ‘void’ should match type ‘int’ src/engine/p_mobj.c:297:6: note: ‘P_ZMovement’ was previously declared here src/engine/g_game.c:71:13: warning: type of ‘M_SaveGame’ does not match original declaration [-Wlto-type-mismatch] 71 | extern void M_SaveGame(void); | ^ src/engine/m_menu.c:3202:6: note: type mismatch in parameter 1 3202 | void M_SaveGame(int choice) { | ^ src/engine/m_menu.c:3202:6: note: type ‘int’ should match type ‘void’ src/engine/m_menu.c:3202:6: note: ‘M_SaveGame’ was previously declared here src/engine/g_game.c:72:13: warning: type of ‘M_LoadGame’ does not match original declaration [-Wlto-type-mismatch] 72 | extern void M_LoadGame(void); | ^ src/engine/m_menu.c:3301:6: note: type mismatch in parameter 1 3301 | void M_LoadGame(int choice) { | ^ src/engine/m_menu.c:3301:6: note: type ‘int’ should match type ‘void’ src/engine/m_menu.c:3301:6: note: ‘M_LoadGame’ was previously declared here
i see, this could be for another pull request.
type mismatch.
fixed lto warnings in new PR.
fixed lto warnings in new PR.
merged your request.
Here are the clang warnings fixed (here listed as errors as I used
-Werror
while addressing them one by one):