Bug 5094 - Code cleanup
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: GIT MASTER
Hardware: All All
: P3 normal
Assignee: Zack Middleton
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2011-07-20 12:05 EDT by Zack Middleton
Modified: 2011-07-31 15:24:24 EDT
2 users (show)

See Also:


Attachments
Fix some warnings, remove/disable some unused code. (91.72 KB, patch)
2011-07-20 12:05 EDT, Zack Middleton
Fix some warnings, remove/disable some unused code. (91.58 KB, patch)
2011-07-20 12:19 EDT, Zack Middleton
refactoring amendments (10.08 KB, patch)
2011-07-21 04:28 EDT, /dev/humancontroller
use some some previously unused sound effects? (2.93 KB, patch)
2011-07-21 04:29 EDT, /dev/humancontroller
Fix some warnings, remove/disable some unused code. (v3) (89.49 KB, patch)
2011-07-27 22:49 EDT, Zack Middleton
Remove two lines of unused code. (903 bytes, patch)
2011-07-29 19:12 EDT, Zack Middleton

Description Zack Middleton 2011-07-20 12:05:14 EDT
Created attachment 2856 [details]
Fix some warnings, remove/disable some unused code.

Fixed many warnings shown by GCC 4.6 and clang static analyzer. Also removed/disabled some other code that was not used.
Comment 1 Zack Middleton 2011-07-20 12:19:09 EDT
Created attachment 2857 [details]
Fix some warnings, remove/disable some unused code.

Removed setting challenge to 0 in CL_ConnectionlessPacket, Thilo already fixed it in r2090.
Comment 2 /dev/humancontroller 2011-07-21 01:59:55 EDT
Thilo: you have been recently working on the VM and the networking code. take a particular look at these hunks (taken from the above patch), and assert that nothing logical has been overlooked around them:

Index: code/qcommon/vm_x86.c
===================================================================
--- code/qcommon/vm_x86.c	(revision 2095)
+++ code/qcommon/vm_x86.c	(working copy)
@@ -1716,7 +1716,6 @@
 {
 	byte	stack[OPSTACK_SIZE + 15];
 	void	*entryPoint;
-	int		programCounter;
 	int		programStack, stackOnEntry;
 	byte	*image;
 	int	*opStack;
@@ -1733,8 +1732,6 @@
 	// set up the stack frame 
 	image = vm->dataBase;
 
-	programCounter = 0;
-
 	programStack -= 48;
 
 	*(int *)&image[ programStack + 44] = args[9];
Index: code/qcommon/net_chan.c
===================================================================
--- code/qcommon/net_chan.c	(revision 2095)
+++ code/qcommon/net_chan.c	(working copy)
@@ -243,7 +243,6 @@
 */
 qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) {
 	int			sequence;
-	int			qport;
 	int			fragmentStart, fragmentLength;
 	qboolean	fragmented;
 
@@ -264,7 +263,7 @@
 
 	// read the qport if we are a server
 	if ( chan->sock == NS_SERVER ) {
-		qport = MSG_ReadShort( msg );
+		MSG_ReadShort( msg );
 	}
 
 #ifdef LEGACY_PROTOCOL
Comment 3 /dev/humancontroller 2011-07-21 04:28:03 EDT
Created attachment 2858 [details]
refactoring amendments

i propose these amendments to the above patch (this patch is to be applied after the above patch).
Comment 4 /dev/humancontroller 2011-07-21 04:29:36 EDT
Created attachment 2859 [details]
use some some previously unused sound effects?

i don't have TA to test, but is using sfx_chghit* appropriate?
Comment 5 Thilo Schulz 2011-07-26 20:54:14 EDT
I have a few questions to your patch, Zack:

You're removing
UI_DemosMenu_Key
Are you sure there is no chance of this function ever being called?

-       s_demos.menu.key = UI_DemosMenu_Key;

What makes you so sure that this callback is not triggered from some other function in another C-file?


Why are you removing:
+       //sfxHandle_t   sfx_chghit;
+       //sfxHandle_t   sfx_chghitflesh;
+       //sfxHandle_t   sfx_chghitmetal;

when it's being used here:
        case WP_CHAINGUN:
                mod = cgs.media.bulletFlashModel;
-               if( soundType == IMPACTSOUND_FLESH ) {
+               /*if( soundType == IMPACTSOUND_FLESH ) {
                        sfx = cgs.media.sfx_chghitflesh;

and why do you disable the use of sfx_chghitflesh?


Aside from that I guess most is fine. Also the variables devhc mentions can be safely removed.
Comment 6 Thilo Schulz 2011-07-26 21:00:28 EDT
Also, ZTurtleMan: Can you please remove the comment lines? Many lines were just commented with //
I say get rid of them, except for cases where surrounding code is already commented or it really makes sense to keep them.
I noticed you also fixed the "noreturn" warnings, even when I did in r2100.. I didn't know you'd tackle this in your patch.

Please keep the changes to con_tty.c in a separate patch.

Is there a way the two of you can somehow consolidate the amandments from devhc into one patch?
Comment 7 Zack Middleton 2011-07-27 18:58:18 EDT
s_demos.menu.key can safely be NULL, it is NULL in most menus. q3_ui uses Menu_DefaultKey if menu key handling function is NULL. Which is all demos menu custom key handler function was doing.

Chaingun sfx gets set to bullet sound after that. The chaingun sounds are never played. I haven't tested Team Arena using them.

Thilo: I'll merge DevHC's patch and do the other things you requested.
Comment 8 Zack Middleton 2011-07-27 22:49:23 EDT
Created attachment 2868 [details]
Fix some warnings, remove/disable some unused code. (v3)

Merged DevHC's patch. Removed con_tty.c changes. I removed a few lines of commented code, I think the rest fall under the exceptions Thilo stated.

There are still three noreturn function declarations added by the patch.
Comment 9 Thilo Schulz 2011-07-28 04:50:35 EDT
(In reply to comment #8)
> Created attachment 2868 [details]
> Fix some warnings, remove/disable some unused code. (v3)
> 
> Merged DevHC's patch. Removed con_tty.c changes. I removed a few lines of
> commented code, I think the rest fall under the exceptions Thilo stated.
> 
> There are still three noreturn function declarations added by the patch.

Thanks alot you for your work! I'll look at this later.
Comment 10 Thilo Schulz 2011-07-29 08:27:11 EDT
applied r2104
Comment 11 Zack Middleton 2011-07-29 19:12:53 EDT
Created attachment 2876 [details]
Remove two lines of unused code.

Sorry, I forgot to include these in the previous patches.
Comment 12 Thilo Schulz 2011-07-31 15:24:24 EDT
(In reply to comment #11)
> Created attachment 2876 [details]
> Remove two lines of unused code.
> 
> Sorry, I forgot to include these in the previous patches.

Fixed r2110