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



commit ada3249cfd7f8b553203094b60c152bb34658470
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..4253c6764 100644
--- a/src/libide/vcs/ide-vcs-cloner.c
+++ b/src/libide/vcs/ide-vcs-cloner.c
@@ -270,7 +270,16 @@ ide_vcs_cloner_clone_simple (IdeContext       *context,
                              GCancellable     *cancellable,
                              GError          **error)
 {
-  CloneSimple state = {0};
+  CloneSimple state = {
+    .context = context,
+    .module_name = module_name,
+    .url = url,
+    .branch = branch,
+    .destination = destination,
+    .notif = notif,
+    .cancellable = cancellable,
+    .error = NULL,
+  };
 
   g_return_val_if_fail (!IDE_IS_MAIN_THREAD (), FALSE);
   g_return_val_if_fail (IDE_IS_CONTEXT (context), FALSE);
@@ -280,15 +289,6 @@ 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;
-
   g_mutex_init (&state.mutex);
   g_cond_init (&state.cond);
 


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