mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-28 17:10:59 +01:00
26735: Check some function return values for failures. Gets rid of
some compiler warnings, and improves error handling/notification.
This commit is contained in:
parent
f0bcd0ecd0
commit
bf25c3a43f
8 changed files with 28 additions and 16 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2009-03-14 Wayne Davison <wayned@users.sourceforge.net>
|
||||
|
||||
* 26735: Src/Modules/files.c, Src/Modules/mapfile.c,
|
||||
Src/Modules/zftp.c, Src/builtin.c, Src/exec.c,
|
||||
Src/hist.c, Src/utils.c: improved return-value checking.
|
||||
|
||||
2009-03-14 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* users/13910: Src/jobs.c: spawnjob() should output job
|
||||
|
|
@ -11403,5 +11409,5 @@
|
|||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.4616 $
|
||||
* $Revision: 1.4617 $
|
||||
*****************************************************
|
||||
|
|
|
|||
|
|
@ -428,7 +428,8 @@ recursivecmd(char *nam, int opt_noerr, int opt_recurse, int opt_safe,
|
|||
if ((err & 2) && ds.dirfd >= 0 && restoredir(&ds) && zchdir(pwd)) {
|
||||
zsfree(pwd);
|
||||
pwd = ztrdup("/");
|
||||
chdir(pwd);
|
||||
if (chdir(pwd) < 0)
|
||||
zwarn("failed to chdir(%s): %e", pwd, errno);
|
||||
}
|
||||
if (ds.dirfd >= 0)
|
||||
close(ds.dirfd);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ setpmmapfile(Param pm, char *value)
|
|||
* First we need to make sure the file is long enough for
|
||||
* when we msync. On AIX, at least, we just get zeroes otherwise.
|
||||
*/
|
||||
ftruncate(fd, len);
|
||||
if (ftruncate(fd, len) < 0)
|
||||
zwarn("ftruncate failed: %e", errno);
|
||||
memcpy(mmptr, value, len);
|
||||
#ifndef MS_SYNC
|
||||
#define MS_SYNC 0
|
||||
|
|
@ -102,7 +103,8 @@ setpmmapfile(Param pm, char *value)
|
|||
* Then we need to truncate again, since mmap() always maps complete
|
||||
* pages. Honestly, I tried it without, and you need both.
|
||||
*/
|
||||
ftruncate(fd, len);
|
||||
if (ftruncate(fd, len) < 0)
|
||||
zwarn("ftruncate failed: %e", errno);
|
||||
munmap(mmptr, len);
|
||||
}
|
||||
#else /* don't USE_MMAP */
|
||||
|
|
|
|||
|
|
@ -2043,8 +2043,9 @@ zfgetinfo(char *prompt, int noecho)
|
|||
fflush(stderr);
|
||||
}
|
||||
|
||||
fgets(instr, 256, stdin);
|
||||
if (instr[len = strlen(instr)-1] == '\n')
|
||||
if (fgets(instr, 256, stdin) == NULL)
|
||||
instr[len = 0] = '\0';
|
||||
else if (instr[len = strlen(instr)-1] == '\n')
|
||||
instr[len] = '\0';
|
||||
|
||||
strret = dupstring(instr);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -2722,7 +2722,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
|
|||
#ifdef HAVE_NICE
|
||||
/* Check if we should run background jobs at a lower priority. */
|
||||
if ((how & Z_ASYNC) && isset(BGNICE))
|
||||
nice(5);
|
||||
if (nice(5) < 0)
|
||||
zwarn("nice(5) failed: %e", errno);
|
||||
#endif /* HAVE_NICE */
|
||||
|
||||
} else if (is_cursh) {
|
||||
|
|
|
|||
|
|
@ -2291,9 +2291,9 @@ savehistfile(char *fn, int err, int writeflags)
|
|||
#ifdef HAVE_FCHMOD
|
||||
if (old_exists && out) {
|
||||
#ifdef HAVE_FCHOWN
|
||||
fchown(fileno(out), sb.st_uid, sb.st_gid);
|
||||
if (fchown(fileno(out), sb.st_uid, sb.st_gid) < 0) {} /* IGNORE FAILURE */
|
||||
#endif
|
||||
fchmod(fileno(out), sb.st_mode);
|
||||
if (fchmod(fileno(out), sb.st_mode) < 0) {} /* IGNORE FAILURE */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5422,7 +5422,8 @@ lchdir(char const *path, struct dirsav *d, int hard)
|
|||
}
|
||||
#ifdef HAVE_LSTAT
|
||||
if (*path == '/')
|
||||
chdir("/");
|
||||
if (chdir("/") < 0)
|
||||
zwarn("failed to chdir(/): %e", errno);
|
||||
for(;;) {
|
||||
while(*path == '/')
|
||||
path++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue