[GRASS5] segment lib speed patch

Markus Neteler neteler at itc.it
Tue Jun 28 06:22:51 EDT 2005


On Mon, Jun 27, 2005 at 04:49:52PM -0700, Brad Douglas wrote:
> On Tue, 2005-06-28 at 11:19 +1200, Hamish wrote:
> > Markus wrote:
> > > +	    return -1;
> >
> > For a long time I have wondered what is best to use for return codes;
> > most modules return 0 for success as per UNIX norms, library fns return
> > all sorts of things, e.g. often 1 for true, etc.. glibc has the same
> > issues with e.g. strcmp(), and I understand is_foo() returning
> > TRUE/FALSE.
> > 
> > esp. for all the  if(G_parser()) exit(-1);  statements in the modules.
> > Should that really be -1 or just 1 or does it matter?
> 
> Isn't it best to use EXIT_FAILURE/EXIT_SUCCESS to avoid idiosyncrasies
> between implementations?

Yes, that's much more intuitive.
In DBMI we have DB_OK and and DB_FAILED.
 
> > It would be nice if we had something standard we could put in the
> > SUBMITTING file. (e.g. action fn()s return 0 on success, test fn()s
> > return 1, or something like that?)
> > 
> > Specifically: should we avoid return -1; ??
> 
> For normal functions that return int, I generally return -1 if some sort
> of error function has been set, but return 0 otherwise.  I don't know
> how applicable that is to GRASS, off hand.
> 
> 
> -- 
> Brad Douglas <rez at touchofmadness.com>


Markus




More information about the grass-dev mailing list