[Freeciv-Dev] Re: 3 suspicous code parts
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Dirk Stoecker <stoecker@xxxxxxxxxxxxxxxxxxxxx> writes:
> Hi,
>
> the source has some suspicous format strings:
>
> server/gamehand.c lines 429 and 719:
> %8X is used, where %X is non-standard. Only lower case %x ist standard.
> I know at least 1 compiler, which does not support %X.
The glibc manual states that %x and %X are exactly equivalent, and
makes no particular mention of %X being a GNU extension. If %x is
more portable there would be little loss in using it instead, off
course.
> clients/options.c lines 272 and 314:
> %2.2d is used, but %d does not support anything with '.'. It is integer
> an not floating point.
I've no idea.
> And another thing:
>
> server/meta.c line 193:
> if ((bad = ((serv_addr.sin_addr.s_addr = inet_addr(servername)) == -1))) {
>
> Isn't the value of type u_long? It is at least on my machine.
uint32_t on my machine. unsigned long is inappropriate because this
is an IPv4 address and thus 32 bits. (long is 64 bits on e.g. alpha.)
The -1 should be changed to INADDR_NONE. Better yet, use inet_aton()
instead since 255.255.255.255 is in fact a valid address.
> So the compiler removes the comparison. Either it must be == (u_long) -1
> or it has no effect:
>
> warning 165 in line 193 of "server/meta.c": comparison redundant
> because operand is unsigned
Odd. Shouldn't -1 be converted into 0xffffffff? This is what the
code is meant to do, anyhow.
What compiler are you using? Is it SAS on the amiga?
--
Big Gaute (not to be confused with LG)
You mean you don't want to watch WRESTLING from ATLANTA?
|
|