From 7ec8928da6e8edce9f451fdd599a252046c72059 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 16 Dec 2022 19:09:32 +0200 Subject: [PATCH 43/43] cityturn.c: Fix NULL derefence clang alalyzer warning From check_city_migrations_player() See osdn #46204 Signed-off-by: Marko Lindqvist --- server/cityturn.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/cityturn.c b/server/cityturn.c index a720d440c6..e9c4923bae 100644 --- a/server/cityturn.c +++ b/server/cityturn.c @@ -4252,10 +4252,10 @@ static bool check_city_migrations_player(const struct player *pplayer) } } iterate_outward_end; - if (best_city_player_score > 0) { - /* first, do the migration within one nation */ + if (best_city_player != NULL) { + /* First, do the migration within one nation */ if (fc_rand(100) >= game.server.mgr_nationchance) { - /* no migration */ + /* No migration */ /* N.B.: city_link always returns the same pointer. */ sz_strlcpy(city_link_text, city_link(pcity)); notify_player(pplayer, city_tile(pcity), E_CITY_TRANSFER, ftc_server, @@ -4266,17 +4266,17 @@ static bool check_city_migrations_player(const struct player *pplayer) do_city_migration(pcity, best_city_player); } - /* stop here */ + /* Stop here */ continue; } - if (best_city_world_score > 0) { - /* second, do the migration between all nations */ + if (best_city_world != NULL) { + /* Second, do the migration between all nations */ if (fc_rand(100) >= game.server.mgr_worldchance) { const char *nname; nname = nation_adjective_for_player(city_owner(best_city_world)); - /* no migration */ + /* No migration */ /* N.B.: city_link always returns the same pointer. */ sz_strlcpy(city_link_text, city_link(pcity)); notify_player(pplayer, city_tile(pcity), E_CITY_TRANSFER, ftc_server, @@ -4289,7 +4289,7 @@ static bool check_city_migrations_player(const struct player *pplayer) internat = TRUE; } - /* stop here */ + /* Stop here */ continue; } } city_list_iterate_safe_end; -- 2.35.1