From edd1b0974c5e1d71f66daf6ad6457f5f6a83da71 Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Fri, 25 Aug 2017 16:24:38 +0100 Subject: [PATCH] gtk/queryimmodules.c: Make the output deterministic. 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=786528 --- gtk/queryimmodules.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gtk/queryimmodules.c b/gtk/queryimmodules.c index fab90fe48a..c7c5c94ed6 100644 --- a/gtk/queryimmodules.c +++ b/gtk/queryimmodules.c @@ -195,13 +195,19 @@ int main (int argc, char **argv) if (dir) { const char *dent; + GList *list = NULL, *iterator = NULL; while ((dent = g_dir_read_name (dir))) + list = g_list_prepend (list, g_strdup (dent)); + + list = g_list_sort (list, (GCompareFunc) strcmp); + for (iterator = list; iterator; iterator = iterator->next) { - if (g_str_has_suffix (dent, SOEXT)) - error |= query_module (dirs[i], dent, contents); + if (g_str_has_suffix (iterator->data, SOEXT)) + error |= query_module (dirs[i], iterator->data, contents); } + g_list_free_full (list, g_free); g_dir_close (dir); }