[Bug 3782] New: Fix compile time warnings (code/server/)

bugzilla-daemon at icculus.org bugzilla-daemon at icculus.org
Wed Sep 17 03:16:29 EDT 2008


http://bugzilla.icculus.org/show_bug.cgi?id=3782

           Summary: Fix compile time warnings (code/server/)
           Product: Quake 3
           Version: SVN HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: trivial
          Priority: P3
         Component: Platform
        AssignedTo: zakk at icculus.org
        ReportedBy: baggett.patrick at figglesoftware.com
         QAContact: quake3-bugzilla at icculus.org


There are many, many compile time warnings when building on SGI IRIX with
MIPSpro C (which is very strict), usually where a variable is set but not used,
or declared but not used. I estimate there are somewhere around 25-50 of them.
This patch eliminates the ones present in the code/server/ folder.

In every case, the variable set is never used, its address is never taken, and
it is never returned nor the argument to a function. It is, as the compiler
notes, not used. In a few cases, it was possible to actually optimize the code
by removing unneeded logic. For example, the following value was not used:

area2 = CM_LeafArea (leafnum);

The implementation of CM_LeafArea (below) does not have any side effects (i.e.
write to global variables, file). Some compilers would not be able detect this
and would add the function call even if they didn't keep the variable
assignment.

int CM_LeafArea( int leafnum ) {
        if ( leafnum < 0 || leafnum >= cm.numLeafs ) {
                Com_Error (ERR_DROP, "CM_LeafArea: bad number");
        }
        return cm.leafs[leafnum].area;
}

Here are the ones I'm getting:

--snip--
CC code/server/sv_client.c
cc-1552 c99: WARNING File = code/server/sv_client.c, Line = 240
  The variable "addrlen" is set but never used.

        int index, addrlen, curbyte, netmask, cmpmask;
                   ^

CC code/server/sv_game.c
cc-1552 c99: WARNING File = code/server/sv_game.c, Line = 188
  The variable "area1" is set but never used.

        int             area1, area2;
                        ^

cc-1552 c99: WARNING File = code/server/sv_game.c, Line = 188
  The variable "area2" is set but never used.

        int             area1, area2;
                               ^

CC code/server/sv_init.c
cc-1552 c99: WARNING File = code/server/sv_init.c, Line = 107
  The variable "len" is set but never used.

        int             len, i;
                        ^

CC code/server/sv_main.c
CC code/server/sv_net_chan.c
cc-1552 c99: WARNING File = code/server/sv_net_chan.c, Line = 37
  The variable "reliableAcknowledge" is set but never used.

        long reliableAcknowledge, i, index;
             ^

CC code/server/sv_snapshot.c
cc-1552 c99: WARNING File = code/server/sv_snapshot.c, Line = 301
  The variable "c_fullsend" is set but never used.

        int             c_fullsend;
                        ^

CC code/server/sv_world.c
cc-1552 c99: WARNING File = code/server/sv_world.c, Line = 385
  The variable "count" is set but never used.

        int                     count;
                                ^

cc-1552 c99: WARNING File = code/server/sv_world.c, Line = 663
  The variable "angles" is set but never used.

        float           *angles;
                         ^
--snip--

After making these changes, I built the binary and hosted a game with a few
bots/players. Everything worked correctly, which makes sense since most of the
variables are optimized out by the compiler. I would like someone to look over
the patch and verify that no side effects exist.


-- 
Configure bugmail: http://bugzilla.icculus.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.



More information about the quake3-bugzilla mailing list