Complete.Org: Mailing Lists: Archives: freeciv-dev: March 1999:
Re: [Freeciv-Dev] warnings
Home

Re: [Freeciv-Dev] warnings

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Fabrice.Noilhan@xxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] warnings
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Thu, 25 Mar 1999 22:34:13 +1100

Fabrice Noilhan wrote:

> on my Solaris 2.6 box, I had some warnings. Most of them were use
> of char instead of `unsigned char' in isalpha and other functions. 

See below.

> There was also:
> 
> xmain.c:316: warning: int format, uid_t arg (arg 3)
> 
> I made the implicit cast myself. uid_t is a long in POSIX.
> 
> and there was an ambiguous else somewhere, I've put brackets according
> to the indentation.

I've applied these two fixes; thanks.

> I've not tested this intensively, but I've not done anything suspicious.
> See the patch below. Maybe shall we use only `unsigned char' instead of
> chars in order to do it The Right Way. It may also produce warnings
> on other systems now...

I think using 'unsigned char' is _not_ the right fix, generally.
The reason is that "strings" are 'char *', not 'unsigned char *',
eg, for passing arguments to strcpy() and similar functions.
So you would just trade one subtle (semi-)problem for another.

The warnings about isalpha etc are a bit annoying, because one
would like them to behave like normal prototyped functions, where 
the arguments are cast to the right type and you only get warnings
if the types are not "compatible" (maybe not the right word).
The warnings are probably because these are implemented as
macros using lookup arrays, and the compiler is worried you 
might be indexing an array using a signed quantity, or something.
One "fix" would be to explicitely cast the arguments (or create
our own wrapper macros which do the cast), although thats still
not ideal because the cast could then potentially hide any real 
problems.

> --GvXjxJ+pjyke8COw
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: attachment; filename=patch
> 
> diff -r freeciv-1.8.0.new/client/optiondlg.c freeciv-1.8.0/client/optiondlg.c
> 361c361
> <   unsigned char *s;
> ---
> >   char *s;

Some diff tips: please use 'diff -u' (and -r etc) or if your diff
doesn't support that, 'diff -c'.  Also, put the old directory first,
then the new directory.

(This reminds me: I've been thinking to write some instructions
(preferences) on submitting bug reports (mostly allready covered 
in README?) and on submitting patches :-)

Regards,
-- David

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