[Pkg-libvirt-commits] [libguestfs] 139/179: tests: switch from get_current_dir_name to getcwd(0, NULL)

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 31 19:08:48 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit 7fcac5f59f80f4deca8a55d77a1d9842dc6b5449
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Wed Oct 22 18:13:49 2014 +0200

    tests: switch from get_current_dir_name to getcwd(0, NULL)
    
    get_current_dir_name exists on GNU libc only, so not portable.
    On the other hand, while POSIX leaves a null buffer argument for getcwd
    as unspecified behaviour, basically the most used/important Unix
    implementations (GNU libc, FreeBSD's libc, etc) allow such value,
    returning a new allocated buffer with the current directory.
    
    In any case, the change just affects two tests, so even if it hits a
    libc not implementing this behaviour for getcwd, only tests are
    affected.
---
 tests/c-api/test-pwd.c                     | 2 +-
 tests/events/test-libvirt-auth-callbacks.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/c-api/test-pwd.c b/tests/c-api/test-pwd.c
index 60b978c..61b88ec 100644
--- a/tests/c-api/test-pwd.c
+++ b/tests/c-api/test-pwd.c
@@ -28,7 +28,7 @@
 int
 main (int argc, char *argv[])
 {
-  char *cwd = get_current_dir_name();
+  char *cwd = getcwd(NULL, 0);
   printf("%s", cwd);
 
   exit (EXIT_SUCCESS);
diff --git a/tests/events/test-libvirt-auth-callbacks.c b/tests/events/test-libvirt-auth-callbacks.c
index 7c26bbe..383f20f 100644
--- a/tests/events/test-libvirt-auth-callbacks.c
+++ b/tests/events/test-libvirt-auth-callbacks.c
@@ -70,9 +70,9 @@ main (int argc, char *argv[])
     exit (EXIT_FAILURE);
   }
 
-  cwd = get_current_dir_name ();
+  cwd = getcwd (NULL, 0);
   if (cwd == NULL) {
-    perror ("get_current_dir_name");
+    perror ("getcwd");
     exit (EXIT_FAILURE);
   }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list