Incidencia #44856

player_distance_to_player() clang analyzer div by zero warning

Abrir Fecha: 2022-06-18 17:11 Última actualización: 2022-06-24 07:14

Informador:
Propietario:
Tipo:
Estado:
Cerrado
Componente:
Prioridad:
5 - Medium
Gravedad:
5 - Medium
Resolución:
Fixed
Fichero:
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
  • Propietario Update from (Ninguno) to cazfi
  • Resolución Update from Ninguno to Accepted
2022-06-24 07:14 Updated by: cazfi
  • Estado Update from Open to Cerrado
  • Resolución Update from Accepted to Fixed

Editar

Please login to add comment to this ticket » Entrar