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 320242 - g_return_* macros in static functions
g_return_* macros in static functions
Status: RESOLVED FIXED
Product: gnome-cups-manager
Classification: Deprecated
Component: gnome-cups-manager
unspecified
Other All
: Normal minor
: ---
Assigned To: Stephane Raimbault
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2005-10-30 15:47 UTC by Stephane Raimbault
Modified: 2008-10-12 19:30 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
Replace g_return_* macros by g_assert or if () return (6.67 KB, patch)
2005-10-30 15:51 UTC, Stephane Raimbault
rejected Details | Review
Replace g_return_* macros by g_assert or if () return (6.71 KB, patch)
2005-10-30 15:57 UTC, Stephane Raimbault
needs-work Details | Review
Remove the g_return_* macros from static private functions (6.03 KB, patch)
2008-08-29 00:06 UTC, Stephane Raimbault
none Details | Review
Remove a useless test (6.12 KB, patch)
2008-10-12 19:22 UTC, Stephane Raimbault
none Details | Review

Description Stephane Raimbault 2005-10-30 15:47:48 UTC
Please describe the problem:
All details here :

http://mail.gnome.org/archives/performance-list/2005-October/msg00005.html



Steps to reproduce:



Actual results:


Expected results:


Does this happen every time?


Other information:
Patch to follow...
Comment 1 Stephane Raimbault 2005-10-30 15:51:36 UTC
Created attachment 54084 [details] [review]
Replace g_return_* macros by g_assert or if () return

If g_assert can be deleted, it's a better solution.
Comment 2 Stephane Raimbault 2005-10-30 15:55:33 UTC
Comment on attachment 54084 [details] [review]
Replace g_return_* macros by g_assert or if () return

Doesn't work
Comment 3 Stephane Raimbault 2005-10-30 15:57:26 UTC
Created attachment 54085 [details] [review]
Replace g_return_* macros by g_assert or if () return
Comment 4 Kjartan Maraas 2005-10-30 22:13:15 UTC
Am I missing something or are those if tests reversed?
Comment 5 Christian Persch 2006-12-16 18:53:00 UTC
This looks indeed wrong to me:

 	model_hash = g_hash_table_lookup (ds->vendors, vendor);
-	g_return_val_if_fail (model_hash != NULL, NULL);
+	if (model_hash != NULL) {
+		g_free (vendor);
+		g_free (model);
+		return NULL;
+	}
Comment 6 Stephane Raimbault 2006-12-18 21:01:46 UTC
Really silly, I will update this patch from gnome-cups-manager HEAD and without smoke crack :)
Comment 7 Stephane Raimbault 2006-12-18 21:49:11 UTC
Code extract:
	
model_hash = g_hash_table_lookup (ds->vendors, vendor);
g_return_val_if_fail (model_hash != NULL, NULL);
drivers = g_hash_table_lookup (model_hash, ppd_model);

g_free (vendor);
g_free (model);


If g_return_val_if_fail is TRUE, we have a nice memory leak but only for the developper because the goal is to compile with G_DISABLE_ASSERT in final releases.

I think it's better to crash application in devel phase with:

model_hash = g_hash_table_lookup (ds->vendors, vendor);
g_assert (model_hash != NULL);
drivers = g_hash_table_lookup (model_hash, ppd_model);

g_free (vendor);
g_free (model);


Like says John Rice (see link to mailing list) graceful failure instead of aborting, masks bugs that we should be catching during debug.

If you are agree with me, patch will be simple, aren't you ?


Comment 8 Stephane Raimbault 2007-07-30 19:40:13 UTC
What do you think about my previous comment?
I need an answer to rewrite my previous patch.
Comment 9 Stephane Raimbault 2008-01-05 12:22:05 UTC
Ping
Comment 10 Kjartan Maraas 2008-01-08 15:33:46 UTC
Sure, let's try it out at least. Not sure how many apps still use gnome-print though?
Comment 11 Kjartan Maraas 2008-01-29 13:09:30 UTC
Moving all gnome-cups-manager bugs to new product. Filter on Kjartan's spring cleaning.
Comment 12 Stephane Raimbault 2008-08-29 00:06:05 UTC
Created attachment 117559 [details] [review]
Remove the g_return_* macros from static private functions

Use g_assert to check 'model_hash'
Comment 13 Stephane Raimbault 2008-08-29 00:07:13 UTC
Can I commit the last patch to close this old bug report?
Comment 14 Stephane Raimbault 2008-10-12 19:22:32 UTC
Created attachment 120458 [details] [review]
Remove a useless test

gtk_tree_model_get_iter_first (model, &iter) already checks the model.