[Freeciv-tickets] [freeciv] #44856: player_distance_to_player() clang analyzer div by zero warning

Zurück zum Archiv-Index
OSDN Ticket System norep****@osdn*****
Sat Jun 18 17:11:46 JST 2022


#44856: player_distance_to_player() clang analyzer div by zero warning

  Open Date: 2022-06-18 11:11
Last Update: 2022-06-18 11:11

URL for this Ticket:
    https://osdn.net//projects/freeciv/ticket/44856
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=44856

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2022-06-18 11:11 Updated by: cazfi
 * New Ticket "player_distance_to_player() clang analyzer div by zero warning" created


---------------------------------------------------------------------
Ticket Status:

      Reporter: cazfi
         Owner: (None)
          Type: Bugs
        Status: Open
      Priority: 5 - Medium
     MileStone: 3.0.3
     Component: General
      Severity: 5 - Medium
    Resolution: None
---------------------------------------------------------------------

Ticket 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 information of Freeciv project
Freeciv Project is hosted on OSDN

Project URL: https://osdn.net/projects/freeciv/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/freeciv/ticket/44856
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=44856



More information about the Freeciv-tickets mailing list
Zurück zum Archiv-Index