GNOME Bugzilla – Bug 669241
glib-2.0: It's okay to pass null in the arg_description field of an OptionEntry.
Last modified: 2012-02-02 14:57:44 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.
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.