summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPino Toscano <toscano.pino@tiscali.it>2015-08-25 23:57:37 +0200
committerPino Toscano <toscano.pino@tiscali.it>2015-08-25 23:57:37 +0200
commit94ec7a292a4b8a75c9e576acfbe9518ecea681fa (patch)
tree7336e425be93769d7e32f79f3860760c6eee07b5
parentf2fb74a0f91d3a714e17f14b84b2b431b82d94e8 (diff)
downloadappstream-glib-94ec7a292a4b8a75c9e576acfbe9518ecea681fa.tar.gz
Avoid using PATH_MAX
realpath() in POSIX.1-2008 supports NULL for the second argument, returning a newly allocated buffer. glibc has been supporting this mode for years already. Thus, switch to this mode and avoid PATH_MAX, which is optional in POSIX and not provided on Hurd.
-rw-r--r--libappstream-builder/asb-self-test.c8
-rw-r--r--libappstream-glib/as-self-test.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c
index 45e7092..7eb38ad 100644
--- a/libappstream-builder/asb-self-test.c
+++ b/libappstream-builder/asb-self-test.c
@@ -43,8 +43,7 @@
static gchar *
asb_test_get_filename (const gchar *filename)
{
- char full_tmp[PATH_MAX];
- gchar *tmp;
+ _cleanup_free_libc_ gchar *tmp = NULL;
_cleanup_free_ gchar *path = NULL;
/* try the source then the destdir */
@@ -53,10 +52,11 @@ asb_test_get_filename (const gchar *filename)
g_free (path);
path = g_build_filename (TESTDIRBUILD, filename, NULL);
}
- tmp = realpath (path, full_tmp);
+ /* glibc allocates a buffer */
+ tmp = realpath (path, NULL);
if (tmp == NULL)
return NULL;
- return g_strdup (full_tmp);
+ return g_strdup (tmp);
}
/**
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 83b583b..b28a927 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -76,15 +76,15 @@ as_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error)
static gchar *
as_test_get_filename (const gchar *filename)
{
- char full_tmp[PATH_MAX];
- gchar *tmp;
+ _cleanup_free_libc_ gchar *tmp = NULL;
_cleanup_free_ gchar *path = NULL;
path = g_build_filename (TESTDATADIR, filename, NULL);
- tmp = realpath (path, full_tmp);
+ /* glibc allocates a buffer */
+ tmp = realpath (path, NULL);
if (tmp == NULL)
return NULL;
- return g_strdup (full_tmp);
+ return g_strdup (tmp);
}
static GMainLoop *_test_loop = NULL;