[GRASS5] Re: src/libes/gmath
Markus Neteler
neteler at itc.it
Fri Aug 31 12:06:27 EDT 2001
Hi again,
concerning the gcc -Wall: I have spend some hours to fix
many warnings within the GRASS library and dbms driver.
However, I fixed "only"
- missing includes added
warning: implicit declaration of function 'exit' -> added
#include <stdlib.h>
warning: implicit declaration of function 'strcmp' -> added
#include <string.h>
etc.
- removed unused variables
The warnings remaining are in (those more severe as Glynn describes below):
documents/compileOutput.log
I would be pretty glad if someone can continue. At least the
GRASS library should be clean. Please track what's done in above file,
thanks.
Markus
On Fri, Aug 31, 2001 at 04:09:43AM +0100, Glynn Clements wrote:
>
> Markus Neteler wrote:
>
> > sorry to disturb again: Currently I try to compile
> > gmath on CRAY. The CRAY compiler finds everything...
>
> gcc will find a lot if you use '-Wall'. Here's a brief analysis of the
> results:
>
> 2759 GRASS_copyright defined but not used
> 1818 unused variable `X'
> 1187 implicit declaration of function `X'
> 827 `X' might be used uninitialized in this function
> 506 return-type defaults to `int'
> 490 suggest parentheses around assignment used as truth value
> 275 control reaches end of non-void function
> 250 `X' defined but not used
> 201 <standard input>:can't break line
> 175 use of `l' length character with `X' type character
> 102 X format, Y arg (arg N)
> 95 passing arg 3 of `Tcl_CreateCommand' from incompatible pointer type
> 93 embedded `\0' in format
> 66 `return' with no value, in function returning non-void
> 35 array subscript has type `char'
> 35 <standard input>:numeric expression expected (got `X')
> 32 suggest explicit braces to avoid ambiguous `else'
> 20 type defaults to `int' in declaration of `X'
> 14 format argument is not a pointer (arg #)
> 11 too many arguments for format
> 11 label `X' defined but not used
> 10 suggest parentheses around && within ||
> 10 `/*' within comment
> 8 suggest parentheses around comparison in operand of &
> 8 ignoring pragma: ident
> 5 value computed is not used
> 5 suggest parentheses around arithmetic in operand of |
> 5 suggest parentheses around + or - inside shift
> 5 missing braces around initializer for `X'
> 5 `X' declared `static' but never defined
> 5 <standard input>:`X' not defined (probable missing space after `X')
> 3 zero-length format string
> 3 unknown conversion type character `X' in format
> 3 too few arguments for format
> 3 suggest parentheses around comparison in operand of |
> 3 statement with no effect
> 2 variable `X' might be clobbered by `longjmp' or `vfork'
> 2 enumeration value `X' not handled in switch
> 2 `0' flag ignored with precision specifier and `d' format
> 1 spurious trailing `%' in format
> 1 no closing `]' for `%[' format
> 1 `main' is usually a function
> 1 <standard input>:can't find special character `X'
> 1 <standard input>:can't find character with input code 12
>
> Total: 9094
>
> Some of these are definitely harmless; others maybe not.
>
> 2759 GRASS_copyright defined but not used
>
> Harmless, although a bit of a nuisance; XEmacs' next-error command is
> a lot less useful when so many warnings are false alarms.
>
> 1187 implicit declaration of function `X'
>
> Many of these can be fixed by adding the correct #include lines.
> Others may need to have the header written.
>
> This can cause problems, particularly for functions which have float
> arguments, or on systems where long is larger than int.
>
> 827 `X' might be used uninitialized in this function
>
> This may indicate a problem, or it may just indicate that the compiler
> can't determine that the variable will always be initialised.
>
> 506 return-type defaults to `int'
>
> Indicates a pre-ANSI prototype without an explicit return type.
> Ideally these would be explicitly declared as returning either int or
> void. Probably harmless.
>
> 490 suggest parentheses around assignment used as truth value
>
> I.e. "if (foo = bar) ...". I found a couple of cases in the gmath
> library where this was a real error. It's quite possible that some of
> those 490 are also errors.
>
> 275 control reaches end of non-void function
>
> Missing "return foo;" at the end of a function which returns a value.
> Some of these are an artifact of the "return-type defaults to int"
> issue, where the function should really return void but implicitly
> returns int. Probably most are harmless, although some might be cases
> where a function may return a garbage result.
>
> 250 `X' defined but not used
>
> Messy but harmless.
>
> 175 use of `l' length character with `X' type character
>
> [where `X' is `E', `e' or `f']
>
> The 'l' modifier isn't valid for FP types in printf() etc (unlike
> scanf() etc). Messy but harmless.
>
> 102 X format, Y arg (arg #)
>
> Most of these look problematic, although about half of those are down
> to these two cases:
>
> 25 int format, long int arg (arg #)
> 28 long int format, int arg (arg #)
>
> Next:
>
> 95 passing arg 3 of `Tcl_CreateCommand' from incompatible pointer type
>
> All of these are in src.contrib/GMSL/NVIZ2.2/src/init_commands.c
>
> 93 embedded `\0' in format
>
> 91 of these are in src/raster/r.agnps50/agnps-source/debugflg.c; the
> author of which appears to have been unaware that string literals are
> automatically NUL terminated.
>
> 66 `return' with no value, in function returning non-void
>
> Some of these are an artifact of the "return-type defaults to int"
> issue.
>
> 35 array subscript has type `char'
>
> In 3 files; this usually causes problems with characters outside of
> the 7-bit range.
>
> Others which indicate actual problems:
>
> 14 format argument is not a pointer (arg N)
> 11 too many arguments for format
> 3 unknown conversion type character `X' in format
> 3 too few arguments for format
>
> It might also be worth looking at the "suggest parentheses" warnings.
>
> --
> Glynn Clements <glynn.clements at virgin.net>
> _______________________________________________
> grass5 mailing list
> grass5 at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass5
More information about the grass-dev
mailing list