[Freeciv-Dev] (PR#2275) compiler warning
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[jdorje - Thu Nov 7 20:26:38 2002]:
> cc1: warnings being treated as errors
> srv_main.c: In function `is_game_over':
> srv_main.c:196: warning: `victor' might be used uninitialized in this
> function
>
> At first I thought this was harmless, but it doesn't appear to be.
> Isn't it possible for all players to be killed simultaneously? The game
> only checks once per turn. If this happens, Bad Things would result.
>
> In fact, I'm sure it's possible. I once played a quick game *by myself*
> to test something out, and ended up being killed by barbarians.
>
> Attached is one possible fix for this. It detects the case of no
> winners. I'm not sure if the reaction is appropriate in this case. It
> also initializes 'victor' to NULL to avoid the spurious warning. It
> might be cleaner to have an if(victor) check down below rather than
> relying on the number of players alive.
>
> jason
your code will never get used unless you change:
/* quit if only one player is left alive */
if (alive <= 1) {
notify_conn(&game.est_connections,
to
/* quit if only one player is left alive */
if (alive == 1) {
notify_conn(&game.est_connections,
-mike
|
|