Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] Re: (PR#6907) aidiplomat: Must check the result of pf_get_
Home

[Freeciv-Dev] Re: (PR#6907) aidiplomat: Must check the result of pf_get_

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#6907) aidiplomat: Must check the result of pf_get_path
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Fri, 21 Nov 2003 08:16:21 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6907 >

On Fri, Nov 21, 2003 at 03:22:27AM -0800, Gregory Berkolaiko wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=6907 >
> 
> On Wed, 19 Nov 2003, Raimar Falke wrote:
> 
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=6907 >
> > 
> > The function can return NULL.
> 
> I don't see the point of this patch/assert.  If path is NULL, there will
> be a crash in ai_unit_execute_path, but how is it different from
> triggering assert?

You show in the code that you understand that the function can return
NULL. If this comment isn't there and someone will copy the code
... it may not break in such obvious manner as it does now.

A comment like 

  /* 
   * ai_unit_execute_path may return NULL but this isn't a problem
   * since it will crash in ai_unit_execute_path soon.
   */

would also be ok. The assert is just shorter.

The best solution however is if you would just react on the NULL value
in a real way (anything except crash).

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Make it idiot-proof and someone will make a better idiot."




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