mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-30 05:40:58 +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
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue