From e5eaca5492d3e08d7d955e475cb4607a2d0fff61 Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Tue, 29 Aug 2017 16:59:56 +0100 Subject: [PATCH] gio-querymodules: Make the output reproducible Whilst working on the Reproducible Builds effort [0], we noticed that queryimmodules generates non-reproducible output as it iterates over the filesystem without sorting. Patch attached. [0] https://reproducible-builds.org/ Signed-off-by: Chris Lamb https://bugzilla.gnome.org/show_bug.cgi?id=786983 --- gio/gio-querymodules.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gio/gio-querymodules.c b/gio/gio-querymodules.c index 667336a66..7abfe07fb 100644 --- a/gio/gio-querymodules.c +++ b/gio/gio-querymodules.c @@ -42,6 +42,7 @@ query_dir (const char *dirname) { GString *data; GDir *dir; + GList *list = NULL, *iterator = NULL; const char *name; char *cachename; char **(* query) (void); @@ -63,11 +64,16 @@ query_dir (const char *dirname) data = g_string_new (""); while ((name = g_dir_read_name (dir))) + list = g_list_prepend (list, g_strdup (name)); + + list = g_list_sort (list, (GCompareFunc) g_strcmp0); + for (iterator = list; iterator; iterator = iterator->next) { GModule *module; gchar *path; char **extension_points; + name = iterator->data; if (!is_valid_module_name (name)) continue; @@ -100,6 +106,7 @@ query_dir (const char *dirname) } g_dir_close (dir); + g_list_free_full (list, g_free); cachename = g_build_filename (dirname, "giomodule.cache", NULL);