After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 338177 - Dead code reported by the coverity checker
Dead code reported by the coverity checker
Status: RESOLVED FIXED
Product: bonobo-activation [was: oaf]
Classification: Deprecated
Component: general
cvs (head)
Other Linux
: Normal normal
: ---
Assigned To: Michael Meeks
Luis Villa
Depends on:
Blocks:
 
 
Reported: 2006-04-12 08:11 UTC by Kjartan Maraas
Modified: 2006-05-02 21:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
possible fix (557 bytes, patch)
2006-05-02 15:13 UTC, Kjartan Maraas
none Details | Review

Description Kjartan Maraas 2006-04-12 08:11:13 UTC
546  	void
547  	bonobo_activation_registration_env_set_global (GSList   *reg_env,
548  						       gboolean  append_if_existing)
549  	{
550  		Bonobo_ActivationEnvValue *old_buffer;
551  		int                        old_length = 0;
552  	
553  		if (append_if_existing)
554  			old_length = global_reg_env._length;
555  	
556  		old_buffer = global_reg_env._buffer;
557  	

Event new_values: Conditional "reg_env == 0"
Also see events: [dead_error_line][dead_error_condition][const][assignment]


Maybe this should be if (!global_reg_env) { ...?

558  		if (!reg_env) {
559  			GSList *l;
560  			int     i;
561  	
562  			global_reg_env._length  = global_reg_env._maximum = old_length + g_slist_length (reg_env);
563  			global_reg_env._buffer  = Bonobo_ActivationEnvironment_allocbuf (global_reg_env._length);
564  			global_reg_env._release = TRUE;
565  	
566  			for (i = 0; i < old_length; i++)
567  				Bonobo_ActivationEnvValue_copy (
568  					&global_reg_env._buffer [i], &old_buffer [i]);
569  	

Event dead_error_condition: On this path, the condition "l != 0" could not be true
Event const: After this line, the value of "l" is equal to 0
Event assignment: Assigning "reg_env" to "l"
Also see events: [dead_error_line][const][assignment][new_values]

570  			for (l = reg_env; l; l = l->next) {

Event dead_error_line: Cannot reach this line of code
Also see events: [dead_error_condition][const][assignment][new_values]

571  				RegistrationEnvValue *val = l->data;
572  	
573  				Bonobo_ActivationEnvValue_set (
574  					&global_reg_env._buffer [++i], val->name, val->value);
575  			}
576  	
577  			g_assert (i == global_reg_env._length - 1);
578  		} else
579  			memset (&global_reg_env, 0, sizeof (Bonobo_ActivationEnvironment));
580  	
581  		if (old_buffer)
582  			CORBA_free (old_buffer);
583  	}
Comment 1 Kjartan Maraas 2006-05-02 15:13:44 UTC
Created attachment 64671 [details] [review]
possible fix
Comment 2 Michael Meeks 2006-05-02 16:43:23 UTC
Hi dudie, good catch - no, it's just the wrong polarity:

- if (!reg_env)
+ if (reg_env)

please do commit that.
Comment 3 Kjartan Maraas 2006-05-02 21:58:38 UTC
Done. Thanks for the review :-)