[ostree] Use { 0, } for structure initialization rather than memset()
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] Use { 0, } for structure initialization rather than memset()
- Date: Sun, 18 Aug 2013 11:21:47 +0000 (UTC)
commit eaee309112cc84909e4961e6dfded1fcafdf90bd
Author: Colin Walters <walters verbum org>
Date: Sat Aug 17 07:59:23 2013 -0400
Use { 0, } for structure initialization rather than memset()
It's cleaner, safer, and I had a totally wrong idea stuck in my head
about why memset() should be used.
https://bugzilla.gnome.org/show_bug.cgi?id=705968
src/libostree/ostree-repo-prune.c | 4 +---
src/libostree/ostree-repo-pull.c | 7 ++-----
src/ostree/ot-admin-deploy.c | 3 +--
src/ostree/ot-builtin-checksum.c | 4 +---
src/ostree/ot-builtin-pull-local.c | 4 +---
src/ostree/ot-builtin-trivial-httpd.c | 4 +---
6 files changed, 7 insertions(+), 19 deletions(-)
---
diff --git a/src/libostree/ostree-repo-prune.c b/src/libostree/ostree-repo-prune.c
index 6492e6e..a64b1c3 100644
--- a/src/libostree/ostree-repo-prune.c
+++ b/src/libostree/ostree-repo-prune.c
@@ -103,11 +103,9 @@ ostree_repo_prune (OstreeRepo *repo,
gs_unref_hashtable GHashTable *objects = NULL;
gs_unref_hashtable GHashTable *all_refs = NULL;
gs_free char *formatted_freed_size = NULL;
- OtPruneData data;
+ OtPruneData data = { 0, };
gboolean refs_only = flags & OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY;
- memset (&data, 0, sizeof (data));
-
data.repo = repo;
data.reachable = ostree_repo_traverse_new_reachable ();
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 14adeca..f108e3c 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -364,12 +364,11 @@ fetch_uri (OtPullData *pull_data,
gboolean ret = FALSE;
gs_free char *uri_string = NULL;
gs_unref_object SoupRequest *request = NULL;
- OstreeFetchUriData fetch_data;
+ OstreeFetchUriData fetch_data = { 0, };
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
- memset (&fetch_data, 0, sizeof (fetch_data));
fetch_data.pull_data = pull_data;
uri_string = soup_uri_to_string (uri, FALSE);
@@ -1184,7 +1183,7 @@ ostree_repo_pull (OstreeRepo *self,
gs_free char *branch_rev = NULL;
gs_free char *remote_mode_str = NULL;
GSource *queue_src = NULL;
- OtPullData pull_data_real;
+ OtPullData pull_data_real = { 0, };
OtPullData *pull_data = &pull_data_real;
SoupURI *summary_uri = NULL;
GKeyFile *config = NULL;
@@ -1194,8 +1193,6 @@ ostree_repo_pull (OstreeRepo *self,
guint64 start_time;
guint64 end_time;
- memset (pull_data, 0, sizeof (*pull_data));
-
pull_data->async_error = error;
pull_data->main_context = g_main_context_get_thread_default ();
pull_data->loop = g_main_loop_new (pull_data->main_context, FALSE);
diff --git a/src/ostree/ot-admin-deploy.c b/src/ostree/ot-admin-deploy.c
index 9bb6f48..89d20eb 100644
--- a/src/ostree/ot-admin-deploy.c
+++ b/src/ostree/ot-admin-deploy.c
@@ -247,7 +247,7 @@ checkout_deployment_tree (GFile *sysroot,
gs_unref_object GFile *osdeploy_path = NULL;
gs_unref_object GFile *deploy_target_path = NULL;
gs_unref_object GFile *deploy_parent = NULL;
- ProcessOneCheckoutData checkout_data;
+ ProcessOneCheckoutData checkout_data = { 0, };
root = (OstreeRepoFile*)ostree_repo_file_new_root (repo, csum);
if (!ostree_repo_file_ensure_resolved (root, error))
@@ -272,7 +272,6 @@ checkout_deployment_tree (GFile *sysroot,
g_print ("ostadmin: Creating deployment %s\n",
gs_file_get_path_cached (deploy_target_path));
- memset (&checkout_data, 0, sizeof (checkout_data));
checkout_data.loop = g_main_loop_new (NULL, TRUE);
checkout_data.error = error;
diff --git a/src/ostree/ot-builtin-checksum.c b/src/ostree/ot-builtin-checksum.c
index 999bdd2..cb61932 100644
--- a/src/ostree/ot-builtin-checksum.c
+++ b/src/ostree/ot-builtin-checksum.c
@@ -61,9 +61,7 @@ ostree_builtin_checksum (int argc, char **argv, GFile *repo_path_path, GCancella
GOptionContext *context;
gboolean ret = FALSE;
gs_unref_object GFile *f = NULL;
- AsyncChecksumData data;
-
- memset (&data, 0, sizeof (data));
+ AsyncChecksumData data = { 0, };
context = g_option_context_new ("FILENAME - Checksum a file or directory");
g_option_context_add_main_entries (context, options, NULL);
diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c
index d98a3a7..23319cf 100644
--- a/src/ostree/ot-builtin-pull-local.c
+++ b/src/ostree/ot-builtin-pull-local.c
@@ -173,14 +173,12 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GCancellable
gs_unref_hashtable GHashTable *commits_to_clone = NULL;
gs_unref_hashtable GHashTable *source_objects = NULL;
gs_unref_hashtable GHashTable *objects_to_copy = NULL;
- OtLocalCloneData datav;
+ OtLocalCloneData datav = { 0, };
OtLocalCloneData *data = &datav;
context = g_option_context_new ("SRC_REPO [REFS...] - Copy data from SRC_REPO");
g_option_context_add_main_entries (context, options, NULL);
- memset (&datav, 0, sizeof (datav));
-
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
diff --git a/src/ostree/ot-builtin-trivial-httpd.c b/src/ostree/ot-builtin-trivial-httpd.c
index f431eff..610e196 100644
--- a/src/ostree/ot-builtin-trivial-httpd.c
+++ b/src/ostree/ot-builtin-trivial-httpd.c
@@ -284,14 +284,12 @@ ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GCancella
gboolean ret = FALSE;
GOptionContext *context;
const char *dirpath;
- OtTrivialHttpd appstruct;
+ OtTrivialHttpd appstruct = { 0, };
OtTrivialHttpd *app = &appstruct;
gs_unref_object GFile *dir = NULL;
gs_unref_object SoupServer *server = NULL;
gs_unref_object GFileMonitor *dirmon = NULL;
- memset (&appstruct, 0, sizeof (appstruct));
-
context = g_option_context_new ("[DIR] - Simple webserver");
g_option_context_add_main_entries (context, options, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]