mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user