Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] Re: (PR#2333) Add function die()
Home

[Freeciv-Dev] Re: (PR#2333) Add function die()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Short via RT <rt@xxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2333) Add function die()
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Sat, 16 Nov 2002 14:52:47 +0100

On Sat, Nov 16, 2002 at 04:09:23AM -0800, Jason Short via RT wrote:
> 
> [rfalke - Thu Nov 14 17:41:44 2002]:
> 
> > 
> > The patch replaces code like below:
> > 
> >      if (team_id == TEAM_NONE) {
> > -      freelog(LOG_ERROR, "Impossible: Too many teams!");
> > -      assert(FALSE);
> > -      exit(EXIT_FAILURE);
> > +      die("Impossible: Too many teams!");
> >      }
> > 
> > with 
> > +  vreal_freelog(LOG_FATAL, format, ap);
> > +  assert(FALSE);
> > +  exit(EXIT_FAILURE);
> > 
> > It simplifies the code (no longer the questions "is it LOG_ERROR or
> > LOG_FATAL" "exit or abort"). And it removes one dependency for
> > stdlib.h.
> 
> Looks clean to me.  This is a lot of code change, but it's all
> shortening the code.
> 
> Now, there are a few places where exit(EXIT_SUCCESS) should be used
> instead of die.

$ grep exit die1.diff |grep -v EXIT_FAILURE|wc -l
      0
$

> And AFAICT it is.  There are other places where exit(EXIT_FAILURE)
> should be used without an abort (e.g., when the user gives bad
> command-line input, or a file is not available, etc.).  die() should
> not be used in this case either.  It's hard to tell whether this is
> done or not.

I agree that dumping the code is not good in all cases:
   if (!found) {
-    freelog(LOG_FATAL,
-           _("Plugin '%s' isn't available. Available are %s"), name,
-           audio_get_all_plugin_names());
-    exit(EXIT_FAILURE);
+    die(_("Plugin '%s' isn't available. Available are %s"), name,
+       audio_get_all_plugin_names());
   }

Solutions:
 - don't convert these
 - add another function user_die or similar
 - add a "bool dump_core" parameter

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Last year, out in California, at a PC users group, there was a demo of
  smart speech recognition software. Before the demonstrator could begin
  his demo, a voice called out from the audience: "Format c, return. Yes,
  return." Damned short demo, it was.


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