Ticket #44856

player_distance_to_player() clang analyzer div by zero warning

오픈 날짜: 2022-06-18 17:11 마지막 업데이트: 2022-06-24 07:14

Reporter:
소유자:
Type:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
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
  • 소유자 Update from (None) to cazfi
  • Resolution Update from None to Accepted
2022-06-24 07:14 Updated by: cazfi
  • Status Update from Open to Closed
  • Resolution Update from Accepted to Fixed

Edit

Please login to add comment to this ticket » Login