Skip to content

Commit

Permalink
Flagged questionable g_main_loop_quit() use with FIXME
Browse files Browse the repository at this point in the history
There are many places that call g_main_loop_quit() followed
by exit() - which does not make too much sense. However these
seem to be on exceptional code paths, so just flagging them
for now.
  • Loading branch information
spiiroin committed Dec 11, 2012
1 parent c55c41a commit 3adc5d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mce-dbus.c
Expand Up @@ -69,6 +69,7 @@ DBusMessage *dbus_new_signal(const gchar *const path,

if ((msg = dbus_message_new_signal(path, interface, name)) == NULL) {
mce_log(LL_CRIT, "No memory for new signal!");
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand All @@ -93,6 +94,7 @@ static DBusMessage *dbus_new_error(DBusMessage *const message,
if ((error_msg = dbus_message_new_error(message, error,
NULL)) == NULL) {
mce_log(LL_CRIT, "No memory for new D-Bus error message!");
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -122,6 +124,7 @@ DBusMessage *dbus_new_method_call(const gchar *const service,
interface, name)) == NULL) {
mce_log(LL_CRIT,
"Cannot allocate memory for D-Bus method call!");
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand All @@ -142,6 +145,7 @@ DBusMessage *dbus_new_method_reply(DBusMessage *const message)

if ((msg = dbus_message_new_method_return(message)) == NULL) {
mce_log(LL_CRIT, "No memory for new reply!");
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand Down
4 changes: 4 additions & 0 deletions mce-dsme.c
Expand Up @@ -127,6 +127,7 @@ static void mce_dsme_send(gpointer msg)
if (dsme_conn == NULL) {
mce_log(LL_CRIT,
"Attempt to use dsme_conn uninitialised; aborting!");
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand All @@ -136,6 +137,7 @@ static void mce_dsme_send(gpointer msg)
"dsmesock_send error: %s",
g_strerror(errno));
#ifdef MCE_DSME_ERROR_POLICY
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
#endif /* MCE_DSME_ERROR_POLICY */
Expand Down Expand Up @@ -426,6 +428,7 @@ static gboolean io_data_ready_cb(GIOChannel *source,
"DSME socket closed; trying to reopen");

if ((init_dsmesock()) == FALSE) {
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -502,6 +505,7 @@ static gboolean io_error_cb(GIOChannel *source,
/* DSME socket closed/error */
mce_log(LL_CRIT,
"DSME socket closed/error, exiting...");
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand Down
3 changes: 3 additions & 0 deletions mce-io.c
Expand Up @@ -703,6 +703,7 @@ static gboolean io_string_cb(GIOChannel *source,
if ((status == FALSE) &&
(iomon != NULL) &&
(iomon->error_policy == MCE_IO_ERROR_POLICY_EXIT)) {
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -875,6 +876,7 @@ static gboolean io_chunk_cb(GIOChannel *source,
if ((status == FALSE) &&
(iomon != NULL) &&
(iomon->error_policy == MCE_IO_ERROR_POLICY_EXIT)) {
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -943,6 +945,7 @@ static gboolean io_error_cb(GIOChannel *source,

EXIT:
if ((iomon != NULL) && (exit_on_error == TRUE)) {
// FIXME: this is not how one should exit from mainloop
g_main_loop_quit(mainloop);
exit(EXIT_FAILURE);
}
Expand Down

0 comments on commit 3adc5d0

Please sign in to comment.