From 788d5752e38f1d9843f5489f625cd62627ca1dd4 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Tue, 17 Sep 2019 11:04:45 +0100 Subject: [PATCH] wrap: Add a NULL to multiarch_tuples This lets us use it as a GStrv-style string array. Signed-off-by: Simon McVittie <smcv@collabora.com> --- src/wrap.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/wrap.c b/src/wrap.c index 2a49d77ed..a621b7365 100644 --- a/src/wrap.c +++ b/src/wrap.c @@ -49,7 +49,8 @@ static const char * const multiarch_tuples[] = { "x86_64-linux-gnu", - "i386-linux-gnu" + "i386-linux-gnu", + NULL }; /* @@ -582,7 +583,9 @@ bind_runtime (FlatpakBwrap *bwrap, "--ro-bind", "/etc/group", "/etc/group", NULL); - for (i = 0; i < G_N_ELEMENTS (multiarch_tuples); i++) + g_assert (multiarch_tuples[G_N_ELEMENTS (multiarch_tuples) - 1] == NULL); + + for (i = 0; i < G_N_ELEMENTS (multiarch_tuples) - 1; i++) { g_autofree gchar *tool = g_strdup_printf ("%s-capsule-capture-libs", multiarch_tuples[i]); @@ -747,6 +750,7 @@ bind_runtime (FlatpakBwrap *bwrap, } /* /lib32 or /lib64 */ + g_assert (i < G_N_ELEMENTS (libquals)); libqual = libquals[i]; dirs = g_new0 (gchar *, 7); @@ -775,7 +779,9 @@ bind_runtime (FlatpakBwrap *bwrap, { GString *archs = g_string_new (""); - for (i = 0; i < G_N_ELEMENTS (multiarch_tuples); i++) + g_assert (multiarch_tuples[G_N_ELEMENTS (multiarch_tuples) - 1] == NULL); + + for (i = 0; i < G_N_ELEMENTS (multiarch_tuples) - 1; i++) { if (archs->len > 0) g_string_append (archs, ", "); @@ -1762,7 +1768,9 @@ main (int argc, * of setting LD_LIBRARY_PATH, for better robustness against * games that set their own LD_LIBRARY_PATH ignoring what they * got from the environment */ - for (i = 0; i < G_N_ELEMENTS (multiarch_tuples); i++) + g_assert (multiarch_tuples[G_N_ELEMENTS (multiarch_tuples) - 1] == NULL); + + for (i = 0; i < G_N_ELEMENTS (multiarch_tuples) - 1; i++) { g_autofree gchar *ld_path = NULL; -- GitLab