From a2b37a495c82ce3191ed1cf47ccb391ed6c3b929 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 23 Sep 2019 13:40:56 +0200 Subject: [PATCH] tests: switch away from xgetcwd xgetcwd is used only in a test, so there is no need to pull a gnulib module just for it. Switch to use getcwd directly with a fixed buffer: the tests would have failed with paths longer than 992 characters, as the libvirt_uri would have been truncated. Since there were no reports of issues, we can assume that the current working directory will fit in 1024 characters; adapt the size of libvirt_uri accordingly. --- tests/c-api/test-add-libvirt-dom.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/c-api/test-add-libvirt-dom.c b/tests/c-api/test-add-libvirt-dom.c index 10224d102..7c7c1bd26 100644 --- a/tests/c-api/test-add-libvirt-dom.c +++ b/tests/c-api/test-add-libvirt-dom.c @@ -28,8 +28,6 @@ #include #include -#include "xgetcwd.h" - #include "guestfs.h" #include "guestfs-utils.h" @@ -76,11 +74,12 @@ main (int argc, char *argv[]) virErrorPtr err; int r; char *backend; - char *cwd; + char cwd[1024]; FILE *fp; - char libvirt_uri[1024]; + char libvirt_uri[sizeof cwd + 64]; - cwd = xgetcwd (); + if (getcwd (cwd, sizeof cwd) == NULL) + error (EXIT_FAILURE, errno, "getcwd"); /* Create the guestfs handle. */ g = guestfs_create (); @@ -147,7 +146,6 @@ main (int argc, char *argv[]) virDomainFree (dom); virConnectClose (conn); - free (cwd); unlink ("test-add-libvirt-dom.xml"); unlink ("test-add-libvirt-dom-1.img");