[GRASS5] GRASS 5.1 v.in.ascii bug

Radim Blazek blazek at itc.it
Thu May 8 04:24:12 EDT 2003


On Wednesday 07 May 2003 05:40 pm, Paul Kelly wrote:
> Hello
> I was trying to run the GRASS 5.1 tour script and encountered a problem
> with v.in.ascii. The imported maps were empty apart from the header
> metadata lines. I looked at the source code and the problem seems to be
> that in vector/v.in.ascii/a2b.c the variable n_points is referenced without
> being initialised to a value. On line 49 there is
>     if (!n_points)
>         continue;
> If I comment out those two lines it seems to work fine. This seems to be
> quite a major bug. Probably that is not the correct solution though.

This was normal bug, I think that remove those lines is correct and I have 
done that.

> Out of interest I tried compiling the same module on Linux using gcc and
> sure enough the warning came up
> a2b.c:21: warning: `n_points' might be used uninitialized in this function
>
> All the new modules seem to generate so many warnings. If we could get rid
> of them it would probably fix a lot of the bugs as well.

I was not using -Wall first, now (circa one year) I am compiling with
-Wall and I aim to make a code which compiles without warnings. 
In all vector/* modules, which may be considered as new, 
I have got only 13 warnings (12 uninitialized, 1 unused).
Did you get more (many) warnings in vector/* modules or in
others? Did you get more warnings on IRIX?

Some of 'uninitialized' may be bugs and when I get this warning
(in new code) I usually try to fix it. However, sometimes I don't know
how to (cleanly) avoid this warning. For example on:

int main( int argc, char **argv ) {
    int i, a, x;
    a = rand();
    if ( a ) {
        i = 1;
        x = 0;
    } else {
        i = 0;
    }
    if ( i ) printf ("%d\n", x);
    exit (0);
}

gcc -Wall prints: warning: `x' might be used uninitialized in this function
IMHO it may not be used uninitialized. Am I missing something?  
Please explain this to me. 
Simply add x=0; at the beginning to avoid this warning doesn't 
seem to be correct.

Radim




More information about the grass-dev mailing list