made a bit more robust
This commit is contained in:
		
							parent
							
								
									7d131a2cd5
								
							
						
					
					
						commit
						46b57440a0
					
				
					 4 changed files with 8 additions and 3 deletions
				
			
		|  | @ -9,7 +9,9 @@ | ||||||
| sys_close(fp) | sys_close(fp) | ||||||
| 	register File *fp; | 	register File *fp; | ||||||
| { | { | ||||||
| 	fp->o_flags = 0; | 	if (fp) { | ||||||
| 	close(fp->o_fd); | 		fp->o_flags = 0; | ||||||
| 	fp->o_fd = -1; | 		close(fp->o_fd); | ||||||
|  | 		fp->o_fd = -1; | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,5 +12,6 @@ sys_read(fp, bufptr, bufsiz, pnbytes) | ||||||
| 	char *bufptr; | 	char *bufptr; | ||||||
| 	int bufsiz, *pnbytes; | 	int bufsiz, *pnbytes; | ||||||
| { | { | ||||||
|  | 	if (! fp) return 0; | ||||||
| 	return (*pnbytes = read(fp->o_fd, bufptr, bufsiz)) >= 0; | 	return (*pnbytes = read(fp->o_fd, bufptr, bufsiz)) >= 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -14,5 +14,6 @@ sys_seek(fp, off, whence, poff) | ||||||
| 	long off; | 	long off; | ||||||
| 	long *poff; | 	long *poff; | ||||||
| { | { | ||||||
|  | 	if (! fp) return 0; | ||||||
| 	return (*poff = lseek(fp->o_fd, off, whence)) >= 0; | 	return (*poff = lseek(fp->o_fd, off, whence)) >= 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,5 +12,6 @@ sys_write(fp, bufptr, nbytes) | ||||||
| 	char *bufptr; | 	char *bufptr; | ||||||
| 	int nbytes; | 	int nbytes; | ||||||
| { | { | ||||||
|  | 	if (! fp) return 0; | ||||||
| 	return write(fp->o_fd, bufptr, nbytes) == nbytes; | 	return write(fp->o_fd, bufptr, nbytes) == nbytes; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue