1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
From f00603d58d844422363b896ea7d07aaf48ddaa66 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@intel.com>
Date: Tue, 1 Apr 2014 17:23:36 +0100
Subject: [PATCH] gdk-pixbuf: add an option so that loader errors are fatal
If an environment variable is specified set the return value from main() to
non-zero if the loader had errors (missing libraries, generally).
Upstream-Status: Pending
Signed-off-by: Ross Burton <ross.burton@intel.com>
---
gdk-pixbuf/queryloaders.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c
index 312aa78..b813d99 100644
--- a/gdk-pixbuf/queryloaders.c
+++ b/gdk-pixbuf/queryloaders.c
@@ -212,7 +212,7 @@ write_loader_info (GString *contents, const char *path, GdkPixbufFormat *info)
g_string_append_c (contents, '\n');
}
-static void
+static gboolean
query_module (GString *contents, const char *dir, const char *file)
{
char *path;
@@ -221,6 +221,7 @@ query_module (GString *contents, const char *dir, const char *file)
void (*fill_vtable) (GdkPixbufModule *module);
gpointer fill_info_ptr;
gpointer fill_vtable_ptr;
+ gboolean ret = TRUE;
if (g_path_is_absolute (file))
path = g_strdup (file);
@@ -270,10 +271,13 @@ query_module (GString *contents, const char *dir, const char *file)
g_module_error());
else
g_fprintf (stderr, "Cannot load loader %s\n", path);
+ ret = FALSE;
}
if (module)
g_module_close (module);
g_free (path);
+
+ return ret;
}
#ifdef G_OS_WIN32
@@ -314,6 +318,7 @@ int main (int argc, char **argv)
gint first_file = 1;
GFile *pixbuf_libdir_file;
gchar *pixbuf_libdir;
+ gboolean success = TRUE;
#ifdef G_OS_WIN32
gchar *libdir;
@@ -452,7 +457,9 @@ int main (int argc, char **argv)
}
modules = g_list_sort (modules, (GCompareFunc)strcmp);
for (l = modules; l != NULL; l = l->next)
- query_module (contents, moduledir, l->data);
+ if (!query_module (contents, moduledir, l->data))
+ success = FALSE;
+
g_list_free_full (modules, g_free);
g_free (moduledir);
#else
@@ -468,7 +475,8 @@ int main (int argc, char **argv)
infilename = g_locale_to_utf8 (infilename,
-1, NULL, NULL, NULL);
#endif
- query_module (contents, cwd, infilename);
+ if (!query_module (contents, cwd, infilename))
+ success = FALSE;
}
g_free (cwd);
}
@@ -486,5 +494,8 @@ int main (int argc, char **argv)
g_free (pixbuf_libdir);
- return 0;
+ if (g_getenv ("GDK_PIXBUF_FATAL_LOADER"))
+ return success ? 0 : 1;
+ else
+ return 0;
}
|