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 669241 - glib-2.0: It's okay to pass null in the arg_description field of an OptionEntry.
glib-2.0: It's okay to pass null in the arg_description field of an OptionEn...
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
0.15.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2012-02-02 12:59 UTC by Alexander Kurtz
Modified: 2012-02-02 14:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (697 bytes, patch)
2012-02-02 12:59 UTC, Alexander Kurtz
none Details | Review

Description Alexander Kurtz 2012-02-02 12:59:58 UTC
Created attachment 206631 [details] [review]
Patch

After enabling --enable-experimental-non-null in one of my projects I found a small bug in the glib-2.0 bindings:
OptionEntry declares its arg_description field to be non-nullable while it's in fact okay to pass null here. In some situations it also does make sense to pass null here:

	$ cat Demo.vala 
	class Demo : Object {
		static int foo;
		static int bar;

		const OptionEntry[] options = {
			{ "foo", 'f', 0, OptionArg.INT, ref foo, "some description for foo", "" },
			{ "bar", 'b', 0, OptionArg.INT, ref bar, "some description for bar", null },
			{ null }
		};

		static void main(string[] arguments){
			OptionContext context = new OptionContext("");
			context.add_main_entries(options, null);
			context.parse(ref arguments);
		}
	}
	$ ./Demo --help
	Usage:
	  Demo [OPTION...]

	Help Options:
	  -h, --help       Show help options

	Application Options:
	  -f, --foo=       some description for foo
	  -b, --bar        some description for bar

	$ 

Please note the missing "=" after "--bar". The attached patch should fix this.
Comment 1 Luca Bruno 2012-02-02 14:57:44 UTC
commit 87483c1d3b22013206c316bee217422058f38bb1
Author: Alexander Kurtz <kurtz.alex@googlemail.com>
Date:   Thu Feb 2 13:47:26 2012 +0100

    glib-2.0: Mark OptionEntry.arg_description as nullable
    
    Fixes bug 669241.

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.