Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2001:
[Freeciv-Dev] Re: Unsafe assertions. (PR#864)
Home

[Freeciv-Dev] Re: Unsafe assertions. (PR#864)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Unsafe assertions. (PR#864)
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: Thu, 26 Jul 2001 22:50:01 +0200

On Thu, 26 Jul 2001, jshort@xxxxxxxxxxxxx wrote:
> Gaute B Strokkenes wrote:
> 
>> The reason this is dangerous is that normaliz_map_pos() will
>> sometimes change the value of x.  If we compile with NDEBUG, this
>> does not happen, and a crash may occur.
>> 
>> I think we should changes these uses to is_real_tile() instead, and
>> use normalize_map_pos() explicitly if we rely on the value of x
>> being normalised afterwards.
> 
> Ouch!  That's bad!
> 
> The assertion is there no doubt because the tile is supposed to be
> normalized to begin with - however, as you point normalize_map_pos
> doesn't check that for the X value.  Unless there's time to debug
> things more, the safest solution for the release would be to move
> normalize_map_pos out of the assertion.  After the release, this can
> be replaced by an assert(is_real_tile(...)) call.
[snip]
> (BTW, I think is_normal_map_pos would be a better name than
> is_real_tile.)

You're confused.  You are mixing the concepts of validity (i.e. "Do a
given set of coordinates refer to an existent tile?" or "y >= 0 && y <
map.ysize") and canonicalisation ("Are these the officially blessed
coordinates for a given tile?" or "x == map_adjust_x(x)").  Think
about it.

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
How's it going in those MODULAR LOVE UNITS??


[Prev in Thread] Current Thread [Next in Thread]