Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: assert(normalize_map_pos(...)) is bad! (PR#1004)
Home

[Freeciv-Dev] Re: assert(normalize_map_pos(...)) is bad! (PR#1004)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: assert(normalize_map_pos(...)) is bad! (PR#1004)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 12 Oct 2001 08:50:19 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Oct 11, 2001 at 02:52:39PM -0700, jdorje@xxxxxxxxxxxxxxxxxxxxx wrote:
> Some of the new (I think) gui-win32 code uses constructs like:
> 
>   assert(normalize_map_pos(&x, &y));
> 
> this is very bad!  normalize_map_pos has side effects, and putting it
> inside an assert will mean (x, y) doesn't get normalized when not in
> debugging mode; you'll get a near-certain segfault.
> 
> Instead you should use either
> 
>   assert(is_real_tile(x, y));
>   normalize_map_pos(&x, &y);
> 
> or
> 
>   int is_real = normalize_map_pos(&x, &y);
>   assert(is_real);
> 

> I think Raimar may be trying to make the latter the standard (although
> if so this should be announced and a macro should be created).

No I hope to remove it altogether.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "These download files are in Microsoft Word 6.0 format. After
  unzipping, these files can be viewed in any text editor, including
  all versions of Microsoft Word, WordPad, and Microsoft Word Viewer."
    -- http://www.microsoft.com/hwdev/pc99.htm


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