Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2001:
[Freeciv-Dev] Re: Compiler-warnings
Home

[Freeciv-Dev] Re: Compiler-warnings

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Compiler-warnings
From: Tony Stuckey <stuckey@xxxxxxxxxxxxxxxxx>
Date: Wed, 24 Jan 2001 16:08:12 -0600

On Wed, Jan 24, 2001 at 09:46:34PM +0100, Raimar Falke wrote:
> So it looks like gcc will accept signed or unsigned char as array
> subscripts. It can also be done using int. Both solution will silence
> the warning but maybe there is also something else to consider.

        It's probably a style error to use signed chars as array
subscripts.  Explicitly adding unsigned to silence these warnings should be
an acceptable patch, once that has been verified to not add any
out-of-range issues.

int has_capability(const char *cap, const char *capstr)
{
  char *capstr_, *token, *next;
  int res=0, finished=0;

  token = capstr_ = mystrdup(capstr);
  do {
    /* skip leading whitespace */
    while (isspace(*token))
      token++;

        Compiling on a sparc running Solaris 8 using GCC, I get this style
of error on the while (isspace(*token)) line above, which does not have any
obvious array subscripting going on, though.  So it's likely that at least
some of these are generated by other means than simply:

char index;
int *lotsa_numbers[120];
...
whee = lotsa_numbers[index];

        style code.  Which is code that probably should be deprecated.
-- 
Anthony J. Stuckey                              stuckey@xxxxxxxxxxxxxxxxx
"And they said work hard, and die suddenly, because it's fun."
        -Robyn Hitchcock.



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