diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2009-03-15 01:04:50 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2009-03-15 01:04:50 +0000 |
commit | bf25c3a43f79f568b55c45e2701f5c961977b47c (patch) | |
tree | eacd272cd739c11b793aa5788bba21fdc6d1205e /Src/builtin.c | |
parent | f0bcd0ecd0896180c5a3f977e086f7237a774d25 (diff) | |
download | zsh-bf25c3a43f79f568b55c45e2701f5c961977b47c.tar.gz zsh-bf25c3a43f79f568b55c45e2701f5c961977b47c.tar.xz zsh-bf25c3a43f79f568b55c45e2701f5c961977b47c.zip |
26735: Check some function return values for failures. Gets rid of
some compiler warnings, and improves error handling/notification.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r-- | Src/builtin.c | 12 |
1 files changed, 6 insertions, 6 deletions
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; |