Re: [patch] add G_GNUC_WARNUNCHECKED define



On Mon, 2004-07-05 at 18:04, Arjan van de Ven wrote:
> Hi,
> 
> gcc versions 3.4 and later have an attribute that you can give to a function
> that will cause gcc to warn if you don't check/use the return value of such
> function. The patch below adds a G_GNUC_WARNUNCHECKED define for this
> attribute. A typical use for this is in realloc() definitions where not
> using the return valueof such functions is always a bad bug in the program.
> The patch below thus adds this attribute to g_realloc() and g_try_realloc().

Sounds vaguely useful; I'm not sure I see a reason to deviate from the
GCC name other than perhaps length. G_GNUC_WARN_UNUSED_RESULT is
certainly more descriptive.

(There is also http://bugzilla.gnome.org/show_bug.cgi?id=113075 
outstanding for "nonnull")

Is the version check right? It's the info page for gcc-3.3.2 that
I have here.

Another concern is that it isn't clear to me if we start adding this
attribute where to stop. There are a *ton* of functions in GLib
and GTK+ that return allocated memory. There are even more functions
that have no side effects other than their return value. In either
of these cases, not using the return value is definitely a bug.

What's the criterion for adding the attribute, simply that we think
it's likely that someone would make the mistake?

Regards,
						Owen

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]