[gnome-builder] diagnostician: cleanup checks



commit 3ef52d7808734275f961b356207118192813a350
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 11 19:19:47 2016 +0300

    diagnostician: cleanup checks

 libide/ide-diagnostician.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/libide/ide-diagnostician.c b/libide/ide-diagnostician.c
index edcb35f..bdb267c 100644
--- a/libide/ide-diagnostician.c
+++ b/libide/ide-diagnostician.c
@@ -86,11 +86,14 @@ diagnose_cb (GObject      *object,
   g_autoptr(GError) error = NULL;
   DiagnoseState *state;
 
-  g_return_if_fail (IDE_IS_DIAGNOSTIC_PROVIDER (provider));
-  g_return_if_fail (G_IS_TASK (task));
+  g_assert (IDE_IS_DIAGNOSTIC_PROVIDER (provider));
+  g_assert (G_IS_TASK (task));
 
   state = g_task_get_task_data (task);
 
+  g_assert (state != NULL);
+  g_assert (state->task == task);
+
   state->active--;
 
   ret = ide_diagnostic_provider_diagnose_finish (provider, result, &error);
@@ -102,9 +105,9 @@ diagnose_cb (GObject      *object,
   ide_diagnostics_unref (ret);
 
 maybe_complete:
-  if (state->total == 1 && error)
+  if (state->total == 1 && error != NULL)
     g_task_return_error (task, g_error_copy (error));
-  else if (!state->active)
+  else if (state->active == 0)
     g_task_return_pointer (task,
                            ide_diagnostics_ref (state->diagnostics),
                            (GDestroyNotify)ide_diagnostics_unref);
@@ -179,11 +182,9 @@ ide_diagnostician_diagnose_finish (IdeDiagnostician  *self,
                                    GAsyncResult      *result,
                                    GError           **error)
 {
-  GTask *task = (GTask *)result;
-
   g_return_val_if_fail (G_IS_TASK (result), NULL);
 
-  return g_task_propagate_pointer (task, error);
+  return g_task_propagate_pointer (G_TASK (result), error);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]