[GRASS-dev] Some simple questions about coding style.

Glynn Clements glynn at gclements.plus.com
Tue Oct 16 07:26:03 EDT 2007


Maris Nartiss wrote:

> I was looking at g.copy source and now I have some simple questions:
> 1) Is it safe to pass int to G_calloc(), as it expects size_t?

Yes.

> 2) Is it safe to G_malloc() fixed amount for parser's option
> description? (opt->description)

Provided that you don't need any more than that. In the case of
g.copy, it should probably either use G_asprintf() or sprintf() into
an oversized local array then make a copy with G_store().

> 3) Why G_warning isn't a viod function? It always returns 0 and none
> of GRASS modules performs check for it's return value.

Much of GRASS uses pre-ANSI conventions where functions always return
a value. We should probably make an effort to fix this stuff once 6.3
is out of the way.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list