diff options
author | Chris Lamb <chris@chris-lamb.co.uk> | 2017-08-25 16:24:38 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-01-16 22:39:03 -0500 |
commit | 6b85162f4342a0b7e09fa9e3ebd059b948a90cab (patch) | |
tree | 9a3b6258722cd881c7d9eae8ab7f72d14a52eb50 | |
parent | 53bc2566b32c978a6fa2f9b7cb2e8c66b9db1748 (diff) | |
download | gtk+-6b85162f4342a0b7e09fa9e3ebd059b948a90cab.tar.gz |
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 <lamby@debian.org>
https://bugzilla.gnome.org/show_bug.cgi?id=786528
-rw-r--r-- | gtk/queryimmodules.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gtk/queryimmodules.c b/gtk/queryimmodules.c index e9978fd322..96b64c75c6 100644 --- a/gtk/queryimmodules.c +++ b/gtk/queryimmodules.c @@ -200,13 +200,19 @@ G_GNUC_END_IGNORE_DEPRECATIONS 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); } |