Fix checks for open() failing. open() may successfully return 0.

ld.c:
Fix a an error message that said that open() failed after fopen() failed.
This commit is contained in:
Bruce Evans 1995-09-28 19:43:22 +00:00
parent 252eedb90d
commit 7da87484df
2 changed files with 6 additions and 6 deletions

View File

@ -32,7 +32,7 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
Set, indirect, and warning symbol features added by Randy Smith. */
/*
* $Id: ld.c,v 1.28 1995/06/14 06:25:09 joerg Exp $
* $Id: ld.c,v 1.29 1995/07/13 08:30:07 rgrimes Exp $
*/
/* Define how to initialize system-dependent header fields. */
@ -959,7 +959,7 @@ file_open(entry)
} else
fd = open(entry->filename, O_RDONLY, 0);
if (fd > 0) {
if (fd >= 0) {
input_file = entry;
input_desc = fd;
return fd;
@ -2475,7 +2475,7 @@ write_output()
outstream = fopen(output_filename, "w");
if (outstream == NULL)
err(1, "open: %s", output_filename);
err(1, "fopen: %s", output_filename);
if (atexit(cleanup))
err(1, "atexit");

View File

@ -1,5 +1,5 @@
/*
* $Id: lib.c,v 1.14 1995/04/07 05:08:28 nate Exp $ - library routines
* $Id: lib.c,v 1.15 1995/05/30 05:01:46 rgrimes Exp $ - library routines
*/
#include <sys/param.h>
@ -830,7 +830,7 @@ struct file_entry *p;
fname = findshlib(p->filename, &major, &minor, 1);
if (fname && (fd = open(fname, O_RDONLY, 0)) > 0) {
if (fname && (fd = open(fname, O_RDONLY, 0)) >= 0) {
p->filename = fname;
p->lib_major = major;
p->lib_minor = minor;
@ -852,7 +852,7 @@ struct file_entry *p;
register char *path
= concat(search_dirs[i], "/", fname);
fd = open(path, O_RDONLY, 0);
if (fd > 0) {
if (fd >= 0) {
p->filename = path;
p->flags &= ~E_SEARCH_DIRS;
break;