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 788302 - daemon: Tidy up main() failure cases
daemon: Tidy up main() failure cases
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: GDM maintainers
GDM maintainers
Depends on:
Blocks:
 
 
Reported: 2017-09-28 18:14 UTC by Robert Ancell
Modified: 2017-09-28 19:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
daemon: Tidy up main() failure cases (2.86 KB, patch)
2017-09-28 18:14 UTC, Robert Ancell
accepted-commit_now Details | Review

Description Robert Ancell 2017-09-28 18:14:23 UTC
Remove goto that no longer does anything.
Consistently use return instead of exit() from main.
Print pre-log errors to stderr to ensure they're visible regardless of GLib
settings.
Comment 1 Robert Ancell 2017-09-28 18:14:25 UTC
Created attachment 360625 [details] [review]
daemon: Tidy up main() failure cases

Remove goto that no longer does anything.
Consistently use return instead of exit() from main.
Print pre-log errors to stderr to ensure they're visible regardless of GLib
settings.
Comment 2 Ray Strode [halfline] 2017-09-28 18:20:06 UTC
Review of attachment 360625 [details] [review]:

sure. since you're here anyway, if you want to do a follow up fix or two...

::: daemon/main.c
@@ +343,3 @@
         if (print_version) {
                 g_print ("GDM %s\n", VERSION);
+                return 1;

it's weird that printing the version returns a value exit code.

@@ +350,3 @@
                 /* make sure the pid file doesn't get wiped */
+                g_printerr ("%s\n", _("Only the root user can run GDM"));
+                return -1;

it's weird to return -1 when exit codes go from 0 to 255. maybe we should use sysexits.h ?
Comment 3 Ray Strode [halfline] 2017-09-28 18:20:40 UTC
s/value exit code/failure value for an exit code/
Comment 4 Robert Ancell 2017-09-28 19:16:51 UTC
I didn't change the error codes because I wasn't sure if they were significant due to the "XDM compliant error message" comment.

I also thought they were weird, so happy to change them to standard ones.