]> sigrok.org Git - libsigrokdecode.git/commitdiff
srd.c: Fix a compiler warning with gcc 8.
authorUwe Hermann <redacted>
Sat, 6 Oct 2018 13:57:49 +0000 (15:57 +0200)
committerUwe Hermann <redacted>
Sat, 6 Oct 2018 13:57:49 +0000 (15:57 +0200)
  srd.c: In function ‘srd_searchpaths_get’:
  srd.c:399:40: warning: cast between incompatible function types from ‘gchar * (*)(const gchar *)’ {aka ‘char * (*)(const char *)’} to ‘void * (*)(const void *, void *)’ [-Wcast-function-type]
    return g_slist_copy_deep(searchpaths, (GCopyFunc)g_strdup, NULL);
                                          ^

Upstream glib issue / documentation change:
https://gitlab.gnome.org/GNOME/glib/issues/1492
https://gitlab.gnome.org/pwithnall/glib/commit/e81f4c2acea5ada6ae989426e462613f7c612cac

srd.c

diff --git a/srd.c b/srd.c
index 5903c6d7e75b748149218ffa459323f5d8ae804b..eb29f61599ce09ecd90f9174ee3051df3d9eae32 100644 (file)
--- a/srd.c
+++ b/srd.c
@@ -396,7 +396,12 @@ err:
  */
 SRD_API GSList *srd_searchpaths_get(void)
 {
-       return g_slist_copy_deep(searchpaths, (GCopyFunc)g_strdup, NULL);
+       GSList *paths = NULL;
+
+       for (GSList *l = searchpaths; l; l = l->next)
+               paths = g_slist_append(paths, g_strdup(l->data));
+
+       return paths;
 }
 
 /** @} */