Handle getcwd failures to satisfy the linter

This commit is contained in:
ridiculousfish 2015-07-26 02:15:59 -07:00
parent c59f5e9f01
commit 78af59f40c

View file

@ -2037,7 +2037,11 @@ static void test_complete(void)
/* File completions */
char saved_wd[PATH_MAX + 1] = {};
(void)getcwd(saved_wd, sizeof saved_wd);
if (!getcwd(saved_wd, sizeof saved_wd))
{
perror("getcwd");
exit(-1);
}
if (system("mkdir -p '/tmp/complete_test/'")) err(L"mkdir failed");
if (system("touch '/tmp/complete_test/testfile'")) err(L"touch failed");
if (chdir("/tmp/complete_test/")) err(L"chdir failed");
@ -3891,7 +3895,11 @@ int main(int argc, char **argv)
while (access("./tests/test.fish", F_OK) != 0)
{
char wd[PATH_MAX + 1] = {};
(void)getcwd(wd, sizeof wd);
if (!getcwd(wd, sizeof wd))
{
perror("getcwd");
exit(-1);
}
if (! strcmp(wd, "/"))
{
fprintf(stderr, "Unable to find 'tests' directory, which should contain file test.fish\n");