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 701318 - Add G_SPAWN_DEFAULT to GSpawnFlags
Add G_SPAWN_DEFAULT to GSpawnFlags
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.37.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-05-30 23:12 UTC by Robert Ancell
Modified: 2014-01-21 08:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add G_SPAWN_DEFAULT so g_spawn_*() can be called without using 0 if no flags required (1.78 KB, patch)
2013-05-30 23:12 UTC, Robert Ancell
committed Details | Review

Description Robert Ancell 2013-05-30 23:12:58 UTC
Created attachment 245684 [details] [review]
Add G_SPAWN_DEFAULT so g_spawn_*() can be called without using 0 if no flags required

Add G_SPAWN_DEFAULT to GSpawnFlags - there is no "no flags" value to use which makes the default use case of g_spawn_*() hard to read (lots of NULL and 0).

i.e.

g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &exit_status, &error)

becomes

g_spawn_sync (NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, NULL, NULL, &exit_status, &error);

This is also nicer in non C languages where, i.e. in Vala:

Process.spawn_sync (null, argv, SpawnFlags.DEFAULT, null, null, null, out exit_status);
Comment 1 Robert Ancell 2013-05-30 23:14:15 UTC
Note I wasn't sure of a good name for the "no flags" case - I would have preferred G_SPAWN_FLAGS_NONE, but none of the other flags have the prefix G_SPAWN_FLAGS_.

We could use G_SPAWN_NO_FLAGS which looks good in C, but other languages will make this look like GSpawnFlags.NO_FLAGS which I'm not sure sounds quite right.
Comment 2 Matthias Clasen 2013-05-31 00:25:23 UTC
You might be able to use nick annotations to tell glib-mkenums which name you prefer, regardless of the C identifier. Of course, various introspection tools might have their own ideas
Comment 3 Ignacio Casal Quinteiro (nacho) 2014-01-21 08:15:55 UTC
This is missing the Since tag no?