From bf25c3a43f79f568b55c45e2701f5c961977b47c Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sun, 15 Mar 2009 01:04:50 +0000 Subject: 26735: Check some function return values for failures. Gets rid of some compiler warnings, and improves error handling/notification. --- Src/builtin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Src/builtin.c') diff --git a/Src/builtin.c b/Src/builtin.c index 050101f5e..95aca06fd 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -795,16 +795,16 @@ bin_cd(char *nam, char **argv, Options ops, int func) setjobpwd(); zsfree(pwd); pwd = metafy(zgetcwd(), -1, META_DUP); - } else if (stat(".", &st2) < 0) - chdir(unmeta(pwd)); - else if (st1.st_ino != st2.st_ino || st1.st_dev != st2.st_dev) { + } else if (stat(".", &st2) < 0) { + if (chdir(unmeta(pwd)) < 0) + zwarn("unable to chdir(%s): %e", pwd, errno); + } else if (st1.st_ino != st2.st_ino || st1.st_dev != st2.st_dev) { if (chasinglinks) { setjobpwd(); zsfree(pwd); pwd = metafy(zgetcwd(), -1, META_DUP); - } else { - chdir(unmeta(pwd)); - } + } else if (chdir(unmeta(pwd)) < 0) + zwarn("unable to chdir(%s): %e", pwd, errno); } unqueue_signals(); return 0; -- cgit 1.4.1