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 584528 - Usage of (allow-none) for return values?
Usage of (allow-none) for return values?
Status: RESOLVED DUPLICATE of bug 626395
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2009-06-01 18:29 UTC by David Zeuthen (not reading bugmail)
Modified: 2015-02-07 16:59 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description David Zeuthen (not reading bugmail) 2009-06-01 18:29:23 UTC
Currently we don't allow (allow-none) for the return value, e.g. I think we just implicitly assume that the return value can always be NULL.

While this is probably the right default, it would be useful to be able to specify that a function can never return NULL. This applies to e.g. g_object_new(). Another example

 /**
  * foo_bar_get_baz:
  * @bar: A #FooBar.
  *
  * Gets the #FooBaz object associated with @bar.
  *
  * Returns: (never-none): A #FooBaz. Free with g_object_unref().
  */
 FooBaz *
 foo_bar_get_baz (FooBar *bar)
 {
   return bar->priv->baz;
 }

This is useful in at least a couple of cases

 - Bindings can handle the cases earlier where a method returns NULL and it 
   shouldn't

 - Things like C++ can return a reference instead of a pointer
   (however I'm not sure this even a good idea - then again, my C++
    knowledge is rather rusty)

However, maybe this is not useful at all. But I thought I'd file a bug anyway.
Comment 1 Johan (not receiving bugmail) Dahlin 2010-09-06 16:48:01 UTC

*** This bug has been marked as a duplicate of bug 626395 ***
Comment 2 André Klapper 2015-02-07 16:59:32 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]