Tíquete #44856

player_distance_to_player() clang analyzer div by zero warning

: 2022-06-18 17:11 Última Atualização: 2022-06-24 07:14

Relator:
Dono:
Tipo:
Estado:
Fechado
Componente:
Marcos:
Prioridade:
5 - Medium
Gravidade:
5 - Medium
Resolução:
Fixed
Arquivo:
2

Details

Clang analyzer giver div by zero warning about player_distance_to_player() line "return MAX(dists / cities, 1);"

There's no bug in there. It's just that the compiler cannot know that "city_list_size(pplayer->cities) == 0" check earlier makes sure that city_list_iterate() makes at least one iteration. Anyway, we should silence the warning, and doing that even speeds up the function.

Ticket History (3/5 Histories)

2022-06-18 17:11 Updated by: cazfi
  • New Ticket "player_distance_to_player() clang analyzer div by zero warning" created
2022-06-18 17:17 Updated by: cazfi
  • Dono Update from (Nenhum) to cazfi
  • Resolução Update from Nenhum to Accepted
2022-06-24 07:14 Updated by: cazfi
  • Estado Update from Aberto to Fechado
  • Resolução Update from Accepted to Fixed

Editar

Please login to add comment to this ticket » Login