[gnome-builder/wip/lantw/fix-a-few-errors-for-clang: 2/2] vcs: initialize the struct directly



commit 846db8e8587de5e23072fd2d5a84223a97ed112a
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Sat Jul 20 16:06:05 2019 +0800

    vcs: initialize the struct directly
    
    Instead of initializing a struct to its zero value and assign values to
    its member afterwards, we can set values for members directly in the
    initializer. This avoids the missing braces warning for clang when the
    first member is a struct or an union whose first member is a pointer.

 src/libide/vcs/ide-vcs-cloner.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/libide/vcs/ide-vcs-cloner.c b/src/libide/vcs/ide-vcs-cloner.c
index f5ecce56c..69d3592e1 100644
--- a/src/libide/vcs/ide-vcs-cloner.c
+++ b/src/libide/vcs/ide-vcs-cloner.c
@@ -270,8 +270,6 @@ ide_vcs_cloner_clone_simple (IdeContext       *context,
                              GCancellable     *cancellable,
                              GError          **error)
 {
-  CloneSimple state = {0};
-
   g_return_val_if_fail (!IDE_IS_MAIN_THREAD (), FALSE);
   g_return_val_if_fail (IDE_IS_CONTEXT (context), FALSE);
   g_return_val_if_fail (module_name != NULL, FALSE);
@@ -280,14 +278,16 @@ ide_vcs_cloner_clone_simple (IdeContext       *context,
   g_return_val_if_fail (!notif || IDE_IS_NOTIFICATION (notif), FALSE);
   g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
 
-  state.context = context;
-  state.module_name = module_name;
-  state.url = url;
-  state.branch = branch;
-  state.destination = destination;
-  state.notif = notif;
-  state.cancellable = cancellable;
-  state.error = NULL;
+  CloneSimple state = {
+    .context = context,
+    .module_name = module_name,
+    .url = url,
+    .branch = branch,
+    .destination = destination,
+    .notif = notif,
+    .cancellable = cancellable,
+    .error = NULL,
+  };
 
   g_mutex_init (&state.mutex);
   g_cond_init (&state.cond);


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