1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

For open/openat, if the flags parameter does not contain O_CREAT, the

3rd (variadic) mode_t parameter is irrelevant.  Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk.  They could all be 0xdeafbeef.
ok millert
This commit is contained in:
deraadt 2021-10-24 21:24:15 +00:00
parent 4f56c6f5d2
commit b7041c0781
133 changed files with 307 additions and 307 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cat.c,v 1.31 2020/12/11 05:48:22 cheloha Exp $ */
/* $OpenBSD: cat.c,v 1.32 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: cat.c,v 1.11 1995/09/07 06:12:54 jtc Exp $ */
/*
@ -208,7 +208,7 @@ raw_args(char **argv)
raw_cat(fileno(stdin), "stdin");
continue;
}
if ((fd = open(*argv, O_RDONLY, 0)) == -1) {
if ((fd = open(*argv, O_RDONLY)) == -1) {
warn("%s", *argv);
rval = 1;
continue;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: chio.c,v 1.28 2021/08/31 05:29:55 robert Exp $ */
/* $OpenBSD: chio.c,v 1.29 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: chio.c,v 1.1.1.1 1996/04/03 00:34:38 thorpej Exp $ */
/*
@ -134,7 +134,7 @@ main(int argc, char *argv[])
changer_name = _PATH_CH;
/* Open the changer device. */
if ((changer_fd = open(changer_name, O_RDWR, 0600)) == -1)
if ((changer_fd = open(changer_name, O_RDWR)) == -1)
err(1, "%s: open", changer_name);
/* Find the specified command. */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: utils.c,v 1.48 2019/06/28 13:34:58 deraadt Exp $ */
/* $OpenBSD: utils.c,v 1.49 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@ -71,7 +71,7 @@ copy_file(FTSENT *entp, int exists)
err(1, "calloc");
}
if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) {
if ((from_fd = open(entp->fts_path, O_RDONLY)) == -1) {
warn("%s", entp->fts_path);
return (1);
}
@ -97,7 +97,7 @@ copy_file(FTSENT *entp, int exists)
(void)close(from_fd);
return 2;
}
to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
to_fd = open(to.p_path, O_WRONLY | O_TRUNC);
} else
to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
fs->st_mode & ~(S_ISTXT | S_ISUID | S_ISGID));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dd.c,v 1.27 2019/06/28 13:34:59 deraadt Exp $ */
/* $OpenBSD: dd.c,v 1.28 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: dd.c,v 1.6 1996/02/20 19:29:06 jtc Exp $ */
/*-
@ -95,7 +95,7 @@ setup(void)
in.name = "stdin";
in.fd = STDIN_FILENO;
} else {
in.fd = open(in.name, O_RDONLY, 0);
in.fd = open(in.name, O_RDONLY);
if (in.fd == -1)
err(1, "%s", in.name);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: exec.c,v 1.74 2019/06/28 13:34:59 deraadt Exp $ */
/* $OpenBSD: exec.c,v 1.75 2021/10/24 21:24:21 deraadt Exp $ */
/*
* execute command tree
@ -1197,7 +1197,7 @@ herein(const char *content, int sub)
* doesn't get removed too soon).
*/
h = maketemp(ATEMP, TT_HEREDOC_EXP, &genv->temps);
if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) == -1) {
if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY)) == -1) {
warningf(true, "can't %s temporary file %s: %s",
!shf ? "create" : "open",
h->name, strerror(errno));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tty.c,v 1.18 2019/06/28 13:34:59 deraadt Exp $ */
/* $OpenBSD: tty.c,v 1.19 2021/10/24 21:24:21 deraadt Exp $ */
#include <errno.h>
#include <fcntl.h>
@ -33,7 +33,7 @@ tty_init(int init_ttystate)
tty_close();
tty_devtty = 1;
tfd = open("/dev/tty", O_RDWR, 0);
tfd = open("/dev/tty", O_RDWR);
if (tfd == -1) {
tty_devtty = 0;
warningf(false, "No controlling tty (open /dev/tty: %s)",

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cp.c,v 1.8 2019/06/28 13:34:59 deraadt Exp $ */
/* $OpenBSD: cp.c,v 1.9 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
@ -386,7 +386,7 @@ copy(char *argv[], enum op type, int fts_options)
}
/* $OpenBSD: cp.c,v 1.8 2019/06/28 13:34:59 deraadt Exp $ */
/* $OpenBSD: cp.c,v 1.9 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@ -455,7 +455,7 @@ copy_file(FTSENT *entp, int dne)
err(1, "calloc");
}
if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) {
if ((from_fd = open(entp->fts_path, O_RDONLY)) == -1) {
warn("%s", entp->fts_path);
return (1);
}
@ -488,7 +488,7 @@ copy_file(FTSENT *entp, int dne)
return (0);
}
}
to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
to_fd = open(to.p_path, O_WRONLY | O_TRUNC);
} else
to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
fs->st_mode & ~(S_ISTXT | S_ISUID | S_ISGID));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mv.c,v 1.46 2019/06/28 13:34:59 deraadt Exp $ */
/* $OpenBSD: mv.c,v 1.47 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: mv.c,v 1.9 1995/03/21 09:06:52 cgd Exp $ */
/*
@ -276,7 +276,7 @@ fastcopy(char *from, char *to, struct stat *sbp)
}
}
if ((from_fd = open(from, O_RDONLY, 0)) == -1) {
if ((from_fd = open(from, O_RDONLY)) == -1) {
warn("%s", from);
return (1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ar_subs.c,v 1.49 2019/06/28 13:34:59 deraadt Exp $ */
/* $OpenBSD: ar_subs.c,v 1.50 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $ */
/*-
@ -448,7 +448,7 @@ wr_archive(ARCHD *arcn, int is_app)
* we were later unable to read (we also purge it from
* the link table).
*/
if ((fd = open(arcn->org_name, O_RDONLY, 0)) < 0) {
if ((fd = open(arcn->org_name, O_RDONLY)) < 0) {
syswarn(1,errno, "Unable to open %s to read",
arcn->org_name);
purg_lnk(arcn);
@ -918,7 +918,7 @@ copy(void)
* have to copy a regular file to the destination directory.
* first open source file and then create the destination file
*/
if ((fdsrc = open(arcn->org_name, O_RDONLY, 0)) < 0) {
if ((fdsrc = open(arcn->org_name, O_RDONLY)) < 0) {
syswarn(1, errno, "Unable to open %s to read",
arcn->org_name);
purg_lnk(arcn);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rm.c,v 1.42 2017/06/27 21:49:47 tedu Exp $ */
/* $OpenBSD: rm.c,v 1.43 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: rm.c,v 1.19 1995/09/07 06:48:50 jtc Exp $ */
/*-
@ -310,7 +310,7 @@ rm_overwrite(char *file, struct stat *sbp)
file, (unsigned long long)sbp->st_ino);
return (0);
}
if ((fd = open(file, O_WRONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1)
if ((fd = open(file, O_WRONLY|O_NONBLOCK|O_NOFOLLOW)) == -1)
goto err;
if (fstat(fd, &sb2))
goto err;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: authenticate.c,v 1.28 2019/12/04 06:25:45 deraadt Exp $ */
/* $OpenBSD: authenticate.c,v 1.29 2021/10/24 21:24:20 deraadt Exp $ */
/*-
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@ -164,7 +164,7 @@ auth_cat(char *file)
int fd, nchars;
char tbuf[8192];
if ((fd = open(file, O_RDONLY, 0)) == -1)
if ((fd = open(file, O_RDONLY)) == -1)
return (0);
while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0)
(void)write(fileno(stdout), tbuf, nchars);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: daemon.c,v 1.7 2010/07/27 22:29:09 marco Exp $ */
/* $OpenBSD: daemon.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -53,7 +53,7 @@ daemon(int nochdir, int noclose)
if (!nochdir)
(void)chdir("/");
if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
(void)dup2(fd, STDERR_FILENO);

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: err.3,v 1.21 2019/05/16 13:35:16 schwarze Exp $
.\" $OpenBSD: err.3,v 1.22 2021/10/24 21:24:20 deraadt Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd $Mdocdate: May 16 2019 $
.Dd $Mdocdate: October 24 2021 $
.Dt ERR 3
.Os
.Sh NAME
@ -166,7 +166,7 @@ information string and exit:
.Bd -literal -offset indent
if ((p = malloc(size)) == NULL)
err(1, NULL);
if ((fd = open(file_name, O_RDONLY, 0)) == -1)
if ((fd = open(file_name, O_RDONLY)) == -1)
err(1, "%s", file_name);
.Ed
.Pp
@ -178,10 +178,10 @@ if (tm.tm_hour < START_TIME)
.Pp
Warn of an error:
.Bd -literal -offset indent
if ((fd = open(raw_device, O_RDONLY, 0)) == -1)
if ((fd = open(raw_device, O_RDONLY)) == -1)
warnx("%s: %s: trying the block device",
raw_device, strerror(errno));
if ((fd = open(block_device, O_RDONLY, 0)) == -1)
if ((fd = open(block_device, O_RDONLY)) == -1)
err(1, "%s", block_device);
.Ed
.Sh SEE ALSO

View File

@ -25,9 +25,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $OpenBSD: getopt.3,v 1.46 2016/01/04 19:43:13 tb Exp $
.\" $OpenBSD: getopt.3,v 1.47 2021/10/24 21:24:20 deraadt Exp $
.\"
.Dd $Mdocdate: January 4 2016 $
.Dd $Mdocdate: October 24 2021 $
.Dt GETOPT 3
.Os
.Sh NAME
@ -178,7 +178,7 @@ while ((ch = getopt(argc, argv, "bf:")) != -1) {
bflag = 1;
break;
case 'f':
if ((fd = open(optarg, O_RDONLY, 0)) == -1)
if ((fd = open(optarg, O_RDONLY)) == -1)
err(1, "%s", optarg);
break;
default:

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: getopt_long.3,v 1.22 2020/01/13 18:05:10 stsp Exp $
.\" $OpenBSD: getopt_long.3,v 1.23 2021/10/24 21:24:20 deraadt Exp $
.\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $
.\"
.\" Copyright (c) 1988, 1991, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95
.\"
.Dd $Mdocdate: January 13 2020 $
.Dd $Mdocdate: October 24 2021 $
.Dt GETOPT_LONG 3
.Os
.Sh NAME
@ -426,7 +426,7 @@ while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1)
bflag = 1;
break;
case 'f':
if ((fd = open(optarg, O_RDONLY, 0)) == -1)
if ((fd = open(optarg, O_RDONLY)) == -1)
err(1, "unable to open %s", optarg);
break;
case 0:

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_aix.c,v 1.7 2020/05/17 14:44:20 deraadt Exp $ */
/* $OpenBSD: getentropy_aix.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2015 Michael Felt <aixtools@gmail.com>
@ -134,7 +134,7 @@ start:
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
fd = open(path, flags, 0);
fd = open(path, flags);
if (fd == -1) {
if (errno == EINTR)
goto start;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_hpux.c,v 1.7 2020/05/17 14:44:20 deraadt Exp $ */
/* $OpenBSD: getentropy_hpux.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@ -138,7 +138,7 @@ start:
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
fd = open(path, flags, 0);
fd = open(path, flags);
if (fd == -1) {
if (errno == EINTR)
goto start;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_linux.c,v 1.47 2020/05/17 14:44:20 deraadt Exp $ */
/* $OpenBSD: getentropy_linux.c,v 1.48 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@ -212,7 +212,7 @@ start:
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
fd = open("/dev/urandom", flags, 0);
fd = open("/dev/urandom", flags);
if (fd == -1) {
if (errno == EINTR)
goto start;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_osx.c,v 1.13 2020/05/17 14:44:20 deraadt Exp $ */
/* $OpenBSD: getentropy_osx.c,v 1.14 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@ -158,7 +158,7 @@ start:
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
fd = open("/dev/urandom", flags, 0);
fd = open("/dev/urandom", flags);
if (fd == -1) {
if (errno == EINTR)
goto start;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_solaris.c,v 1.14 2020/05/17 14:44:20 deraadt Exp $ */
/* $OpenBSD: getentropy_solaris.c,v 1.15 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@ -164,7 +164,7 @@ start:
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
fd = open(path, flags, 0);
fd = open(path, flags);
if (fd == -1) {
if (errno == EINTR)
goto start;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: read_termcap.c,v 1.22 2010/01/12 23:22:06 nicm Exp $ */
/* $OpenBSD: read_termcap.c,v 1.23 2021/10/24 21:24:20 deraadt Exp $ */
/****************************************************************************
* Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
@ -60,7 +60,7 @@
#include <tic.h>
#include <term_entry.h>
MODULE_ID("$Id: read_termcap.c,v 1.22 2010/01/12 23:22:06 nicm Exp $")
MODULE_ID("$Id: read_termcap.c,v 1.23 2021/10/24 21:24:20 deraadt Exp $")
#if !PURE_TERMINFO
@ -316,7 +316,7 @@ _nc_getent(
if (fd >= 0) {
(void) lseek(fd, (off_t) 0, SEEK_SET);
} else if ((_nc_access(db_array[current], R_OK) < 0)
|| (fd = open(db_array[current], O_RDONLY, 0)) < 0) {
|| (fd = open(db_array[current], O_RDONLY)) < 0) {
/* No error on unfound file. */
if (errno == ENOENT)
continue;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: keynote-sign.c,v 1.19 2019/06/28 13:32:42 deraadt Exp $ */
/* $OpenBSD: keynote-sign.c,v 1.20 2021/10/24 21:24:20 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
*
@ -103,7 +103,7 @@ keynote_sign(int argc, char *argv[])
algname = argv[1 + flg];
/* Read assertion */
fd = open(argv[2 + flg], O_RDONLY, 0);
fd = open(argv[2 + flg], O_RDONLY);
if (fd == -1)
{
perror(argv[2 + flg]);
@ -139,7 +139,7 @@ keynote_sign(int argc, char *argv[])
close(fd);
/* Read private key file */
fd = open(argv[3 + flg], O_RDONLY, 0);
fd = open(argv[3 + flg], O_RDONLY);
if (fd == -1)
{
perror(argv[3 + flg]);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: keynote-sigver.c,v 1.17 2019/06/28 13:32:42 deraadt Exp $ */
/* $OpenBSD: keynote-sigver.c,v 1.18 2021/10/24 21:24:20 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
*
@ -56,7 +56,7 @@ keynote_sigver(int argc, char *argv[])
}
/* Open and read assertion file */
fd = open(argv[1], O_RDONLY, 0);
fd = open(argv[1], O_RDONLY);
if (fd == -1)
{
perror(argv[1]);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: keynote-verify.c,v 1.19 2021/01/18 00:53:20 mortimer Exp $ */
/* $OpenBSD: keynote-verify.c,v 1.20 2021/10/24 21:24:20 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
*
@ -104,7 +104,7 @@ keynote_verify(int argc, char *argv[])
case 'k':
sk = 1;
if ((fd = open(optarg, O_RDONLY, 0)) == -1)
if ((fd = open(optarg, O_RDONLY)) == -1)
{
perror(optarg);
exit(1);
@ -224,7 +224,7 @@ keynote_verify(int argc, char *argv[])
break;
case 'l':
if ((fd = open(optarg, O_RDONLY, 0)) == -1)
if ((fd = open(optarg, O_RDONLY)) == -1)
{
perror(optarg);
exit(1);
@ -308,7 +308,7 @@ keynote_verify(int argc, char *argv[])
while (argc--)
{
if ((fd = open(argv[argc], O_RDONLY, 0)) == -1)
if ((fd = open(argv[argc], O_RDONLY)) == -1)
{
perror(argv[argc]);
exit(1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: check_expire.c,v 1.13 2019/06/28 13:32:43 deraadt Exp $ */
/* $OpenBSD: check_expire.c,v 1.14 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@ -173,7 +173,7 @@ pwd_update(const struct passwd *pwd, const struct passwd *opwd)
return("can't open passwd temp file");
}
pfd = open(_PATH_MASTERPASSWD, O_RDONLY|O_CLOEXEC, 0);
pfd = open(_PATH_MASTERPASSWD, O_RDONLY|O_CLOEXEC);
if (pfd == -1) {
pw_abort();
return(strerror(errno));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: logwtmp.c,v 1.13 2021/05/23 17:01:21 jan Exp $ */
/* $OpenBSD: logwtmp.c,v 1.14 2021/10/24 21:24:20 deraadt Exp $ */
/* $NetBSD: logwtmp.c,v 1.4 1995/04/11 02:44:58 cgd Exp $ */
/*
@ -60,7 +60,7 @@ ftpdlogwtmp(const char *line, const char *name, const char *host)
struct stat buf;
struct utmp ut;
if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) == -1)
if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND)) == -1)
return;
if (fstat(fd, &buf) == 0) {
(void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: monitor.c,v 1.29 2021/05/31 16:18:01 jan Exp $ */
/* $OpenBSD: monitor.c,v 1.30 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2004 Moritz Jodeit <moritz@openbsd.org>
@ -223,7 +223,7 @@ monitor_post_auth(void)
}
/* We have to keep stdout open, because reply() needs it. */
if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
if ((nullfd = open(_PATH_DEVNULL, O_RDWR)) == -1)
fatalx("cannot open %s: %m", _PATH_DEVNULL);
dup2(nullfd, STDIN_FILENO);
dup2(nullfd, STDERR_FILENO);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ldconfig.c,v 1.38 2018/06/08 19:24:46 cheloha Exp $ */
/* $OpenBSD: ldconfig.c,v 1.39 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 1993,1995 Paul Kranenburg
@ -432,7 +432,7 @@ readhints(void)
long msize;
int fd, i;
if ((fd = open(_PATH_LD_HINTS, O_RDONLY, 0)) == -1) {
if ((fd = open(_PATH_LD_HINTS, O_RDONLY)) == -1) {
warn("%s", _PATH_LD_HINTS);
return -1;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dbtest.c,v 1.17 2020/02/14 19:17:33 schwarze Exp $ */
/* $OpenBSD: dbtest.c,v 1.18 2021/10/24 21:24:20 deraadt Exp $ */
/* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */
/*-
@ -680,7 +680,7 @@ rfile(name, lenp)
for (; isspace((unsigned char)*name); ++name);
if ((np = strchr(name, '\n')) != NULL)
*np = '\0';
if ((fd = open(name, O_RDONLY, 0)) < 0 ||
if ((fd = open(name, O_RDONLY)) < 0 ||
fstat(fd, &sb))
dberr("%s: %s\n", name, strerror(errno));
if (sb.st_size > (off_t)INT_MAX)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: t_truncate.c,v 1.1.1.1 2019/11/19 19:57:04 bluhm Exp $ */
/* $OpenBSD: t_truncate.c,v 1.2 2021/10/24 21:24:20 deraadt Exp $ */
/* $NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $ */
/*-
@ -96,7 +96,7 @@ ATF_TC_BODY(ftruncate_err, tc)
{
int fd;
fd = open("/etc/passwd", O_RDONLY, 0400);
fd = open("/etc/passwd", O_RDONLY);
ATF_REQUIRE(fd >= 0);
errno = 0;

View File

@ -306,7 +306,7 @@ main(int argc, char **argv)
events |= POLLIN;
}
if (playpath) {
playfd = open(playpath, O_RDONLY, 0);
playfd = open(playpath, O_RDONLY);
if (playfd < 0) {
perror(playpath);
exit(1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: videotest.c,v 1.5 2015/11/17 07:13:55 mmcc Exp $ */
/* $OpenBSD: videotest.c,v 1.6 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2010 Marcus Glocker <mglocker@openbsd.org>
@ -117,7 +117,7 @@ main(void)
DEV_PATH, dev_name);
/* open video device */
fd = open(dev_full, O_RDWR, 0);
fd = open(dev_full, O_RDWR);
if (fd == -1) {
warn("%s", dev_full);
break;
@ -317,7 +317,7 @@ test_capture(char *dev_name, char *dev_full, int access, int use_poll)
}
/* open device */
fd1 = open(dev_full, O_RDWR, 0);
fd1 = open(dev_full, O_RDWR);
if (fd1 == -1)
err(1, "open");
sleep(WAIT_INIT); /* let device initialize */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.10 2017/12/15 14:45:51 bluhm Exp $ */
/* $OpenBSD: main.c,v 1.11 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org>
*
@ -74,7 +74,7 @@ test_rpath()
int fd;
char data[512];
if ((fd = open("/dev/zero", O_RDONLY, 0)) == -1)
if ((fd = open("/dev/zero", O_RDONLY)) == -1)
_exit(errno);
if (read(fd, data, sizeof(data)) == -1)
@ -89,7 +89,7 @@ test_wpath()
int fd;
char data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
if ((fd = open("/dev/null", O_WRONLY, 0)) == -1)
if ((fd = open("/dev/null", O_WRONLY)) == -1)
_exit(errno);
if (write(fd, data, sizeof(data)) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ptmget.c,v 1.3 2016/08/27 04:34:28 guenther Exp $ */
/* $OpenBSD: ptmget.c,v 1.4 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Written by Bob Beck <beck@openbsd.org> 2004 Public Domain.
* Basic test to ensure /dev/ptm works, and what it returns
@ -31,7 +31,7 @@ main(int argc, char *argv[])
ttygid = gr->gr_gid;
else
ttygid = 4;
fd = open("/dev/ptm", O_RDWR, 0);
fd = open("/dev/ptm", O_RDWR);
if (fd == -1)
err(1, "Can't open /dev/ptm");
if ((ioctl(fd, PTMGET, &ptm) == -1))

View File

@ -1,4 +1,4 @@
/* $OpenBSD: unfdpass.c,v 1.20 2018/11/28 08:06:22 claudio Exp $ */
/* $OpenBSD: unfdpass.c,v 1.21 2021/10/24 21:24:20 deraadt Exp $ */
/* $NetBSD: unfdpass.c,v 1.3 1998/06/24 23:51:30 thorpej Exp $ */
/*-
@ -303,7 +303,7 @@ child(int sock, int type, int oflag)
files = (int *)CMSG_DATA(cmp);
for (i = 0; i < nfds; i++) {
(void) snprintf(fname, sizeof fname, "file%d", i + 1);
if ((fd = open(fname, O_RDONLY, 0666)) == -1)
if ((fd = open(fname, O_RDONLY)) == -1)
err(1, "child open %s", fname);
files[i] = fd;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mmap0.c,v 1.2 2016/08/27 04:35:19 guenther Exp $ */
/* $OpenBSD: mmap0.c,v 1.3 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
*
@ -37,7 +37,7 @@ main()
int errors = 0;
int fd;
fd = open("/dev/zero", O_RDWR, 0);
fd = open("/dev/zero", O_RDWR);
if (fd == -1)
err(EX_OSERR, "open");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mmap_4g.c,v 1.4 2019/09/20 12:52:30 bluhm Exp $ */
/* $OpenBSD: mmap_4g.c,v 1.5 2021/10/24 21:24:21 deraadt Exp $ */
/*
* Public domain. 2005, Otto Moerbeek <otto@drijf.net>
@ -40,7 +40,7 @@ main()
err(1, "write");
close(fd);
fd = open(file, O_RDWR, 0);
fd = open(file, O_RDWR);
if (fd == -1)
err(1, "open");
p = mmap(NULL, 100, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED,
@ -53,7 +53,7 @@ main()
err(1, "munmap");
close(fd);
fd = open(file, O_RDONLY, 0);
fd = open(file, O_RDONLY);
if (fd == -1)
err(1, "open");
if (read(fd, buf, sz) != sz)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: logflush.c,v 1.1 2021/03/09 15:16:28 bluhm Exp $ */
/* $OpenBSD: logflush.c,v 1.2 2021/10/24 21:24:21 deraadt Exp $ */
/*
* Copyright (c) 2021 Alexander Bluhm <bluhm@openbsd.org>
@ -52,7 +52,7 @@ main(int argc, char *argv[])
if (setsockopt(pair[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)) == -1)
err(1, "setsockopt SO_SNDBUF");
if ((klog = open(_PATH_KLOG, O_RDONLY, 0)) == -1)
if ((klog = open(_PATH_KLOG, O_RDONLY)) == -1)
err(1, "open %s", _PATH_KLOG);
/* Use /dev/klog to register sendsyslog(2) receiver. */
if (ioctl(klog, LIOCSFD, &pair[1]) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dhclient.c,v 1.725 2021/08/25 21:07:47 krw Exp $ */
/* $OpenBSD: dhclient.c,v 1.726 2021/10/24 21:24:21 deraadt Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@ -703,7 +703,7 @@ main(int argc, char *argv[])
socket_fd) == -1)
fatal("socketpair");
if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
if ((nullfd = open(_PATH_DEVNULL, O_RDWR)) == -1)
fatal("open(%s)", _PATH_DEVNULL);
fork_privchld(ifi, socket_fd[0], socket_fd[1]);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: init.c,v 1.70 2020/03/25 19:26:52 cheloha Exp $ */
/* $OpenBSD: init.c,v 1.71 2021/10/24 21:24:21 deraadt Exp $ */
/* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */
/*-
@ -205,7 +205,7 @@ main(int argc, char *argv[])
/*
* Paranoia.
*/
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
if ((fd = open(_PATH_DEVNULL, O_RDWR)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
(void)dup2(fd, STDERR_FILENO);
@ -1025,7 +1025,7 @@ start_getty(session_t *sp)
int fd;
close(p[0]);
fd = open(sp->se_device, O_RDONLY | O_NONBLOCK, 0666);
fd = open(sp->se_device, O_RDONLY | O_NONBLOCK);
if (fd == -1 && (errno == ENXIO || errno == ENOENT ||
errno == EISDIR)) {
(void)write(p[1], "0", 1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: monitor.c,v 1.81 2020/01/24 02:14:08 yasuoka Exp $ */
/* $OpenBSD: monitor.c,v 1.82 2021/10/24 21:24:21 deraadt Exp $ */
/*
* Copyright (c) 2003 Håkan Olsson. All rights reserved.
@ -858,7 +858,7 @@ m_priv_req_readdir()
if (m_priv_local_sanitize_path(path, sizeof path, O_RDONLY)
!= 0)
continue;
fd = open(path, O_RDONLY, 0);
fd = open(path, O_RDONLY);
if (fd == -1) {
log_error("m_priv_req_readdir: open "
"(\"%s\", O_RDONLY, 0) failed", path);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ui.c,v 1.57 2017/12/05 20:31:45 jca Exp $ */
/* $OpenBSD: ui.c,v 1.58 2021/10/24 21:24:21 deraadt Exp $ */
/* $EOM: ui.c,v 1.43 2000/10/05 09:25:12 niklas Exp $ */
/*
@ -96,7 +96,7 @@ ui_init(void)
if (mkfifo(ui_fifo, 0600) == -1)
log_fatal("ui_init: mkfifo (\"%s\", 0600) failed", ui_fifo);
ui_socket = open(ui_fifo, O_RDWR | O_NONBLOCK, 0);
ui_socket = open(ui_fifo, O_RDWR | O_NONBLOCK);
if (ui_socket == -1)
log_fatal("ui_init: open (\"%s\", O_RDWR | O_NONBLOCK, 0) "
"failed", ui_fifo);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mount_udf.c,v 1.8 2019/06/28 13:32:45 deraadt Exp $ */
/* $OpenBSD: mount_udf.c,v 1.9 2021/10/24 21:24:22 deraadt Exp $ */
/*
* Copyright (c) 2005 Pedro Martelletto <pedro@ambientworks.net>
@ -55,7 +55,7 @@ lastblock(char *dev)
struct ioc_read_toc_entry t;
struct cd_toc_entry te;
fd = open(dev, O_RDONLY, 0);
fd = open(dev, O_RDONLY);
if (fd == -1)
err(1, "open");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: symtab.c,v 1.23 2019/06/28 13:32:46 deraadt Exp $ */
/* $OpenBSD: symtab.c,v 1.24 2021/10/24 21:24:22 deraadt Exp $ */
/* $NetBSD: symtab.c,v 1.10 1997/03/19 08:42:54 lukem Exp $ */
/*
@ -536,7 +536,7 @@ initsymtable(char *filename)
ep->e_flags |= NEW;
return;
}
if ((fd = open(filename, O_RDONLY, 0)) == -1) {
if ((fd = open(filename, O_RDONLY)) == -1) {
warn("open");
panic("cannot open symbol table file %s\n", filename);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: savecore.c,v 1.62 2019/06/28 13:32:46 deraadt Exp $ */
/* $OpenBSD: savecore.c,v 1.63 2021/10/24 21:24:22 deraadt Exp $ */
/* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */
/*-
@ -644,7 +644,7 @@ check_space(void)
exit(1);
}
kernelsize = st.st_blocks * S_BLKSIZE;
if ((fd = open(dirn, O_RDONLY, 0)) == -1 || fstatfs(fd, &fsbuf) == -1) {
if ((fd = open(dirn, O_RDONLY)) == -1 || fstatfs(fd, &fsbuf) == -1) {
syslog(LOG_ERR, "%s: %m", dirn);
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ttyflags.c,v 1.15 2019/06/04 15:45:58 otto Exp $ */
/* $OpenBSD: ttyflags.c,v 1.16 2021/10/24 21:24:22 deraadt Exp $ */
/* $NetBSD: ttyflags.c,v 1.8 1996/04/09 05:20:30 cgd Exp $ */
/*
@ -199,7 +199,7 @@ ttyflags(struct ttyent *tep, int print)
return (0);
/* Open the device NON-BLOCKING, set the flags, and close it. */
if ((fd = open(path, O_RDONLY | O_NONBLOCK, 0)) == -1) {
if ((fd = open(path, O_RDONLY | O_NONBLOCK)) == -1) {
if (!(errno == ENXIO ||
(errno == ENOENT && (st & TTY_ON) == 0)))
rval = 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: headersize.c,v 1.10 2013/10/15 05:17:31 deraadt Exp $ */
/* $OpenBSD: headersize.c,v 1.11 2021/10/24 21:24:22 deraadt Exp $ */
/* $NetBSD: headersize.c,v 1.5 1996/09/23 04:32:59 cgd Exp $ */
/*
@ -59,7 +59,7 @@ main(argc, argv)
errx(1, "load addr argument (%s) not valid", argv[1]);
fname = argv[2];
if ((fd = open(fname, O_RDONLY, 0)) == -1)
if ((fd = open(fname, O_RDONLY)) == -1)
err(1, "%s: open failed", fname);
if (read(fd, &buf, HDR_BUFSIZE) != HDR_BUFSIZE)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: setnetbootinfo.c,v 1.4 2014/07/12 19:01:49 tedu Exp $ */
/* $OpenBSD: setnetbootinfo.c,v 1.5 2021/10/24 21:24:22 deraadt Exp $ */
/* $NetBSD: setnetbootinfo.c,v 1.5 1997/04/06 08:41:37 cgd Exp $ */
/*
@ -168,7 +168,7 @@ main(argc, argv)
if (verbose)
printf("opening %s...\n", netboot);
if ((fd = open(netboot, O_RDONLY, 0)) == -1)
if ((fd = open(netboot, O_RDONLY)) == -1)
err(1, "open: %s", netboot);
if (fstat(fd, &sb) == -1)
err(1, "fstat: %s", netboot);

View File

@ -895,7 +895,7 @@ afile_open(struct afile *f, char *path, int hdr, int flags,
f->fd = STDIN_FILENO;
} else {
f->path = path;
f->fd = open(f->path, O_RDONLY, 0);
f->fd = open(f->path, O_RDONLY);
if (f->fd == -1) {
log_puts(f->path);
log_puts(": failed to open for reading\n");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: io.c,v 1.49 2019/06/28 13:35:00 deraadt Exp $ */
/* $OpenBSD: io.c,v 1.50 2021/10/24 21:24:16 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@ -355,7 +355,7 @@ opencal(void)
*/
if (doall) {
int fderr;
fderr = open(_PATH_DEVNULL, O_WRONLY, 0);
fderr = open(_PATH_DEVNULL, O_WRONLY);
if (fderr == -1)
_exit(0);
(void)dup2(fderr, STDERR_FILENO);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cdio.c,v 1.81 2021/08/13 10:56:54 schwarze Exp $ */
/* $OpenBSD: cdio.c,v 1.82 2021/10/24 21:24:16 deraadt Exp $ */
/* Copyright (c) 1995 Serge V. Vakulenko
* All rights reserved.
@ -645,7 +645,7 @@ tao(int argc, char **argv)
if (argv[0] == NULL)
usage();
tr->file = argv[0];
tr->fd = open(tr->file, O_RDONLY, 0640);
tr->fd = open(tr->file, O_RDONLY);
if (tr->fd == -1)
err(1, "cannot open file %s", tr->file);
if (fstat(tr->fd, &sb) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: chpass.c,v 1.47 2021/07/12 15:09:19 beck Exp $ */
/* $OpenBSD: chpass.c,v 1.48 2021/10/24 21:24:16 deraadt Exp $ */
/* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */
/*-
@ -206,7 +206,7 @@ main(int argc, char *argv[])
}
if (i >= 4)
fputc('\n', stderr);
pfd = open(_PATH_MASTERPASSWD, O_RDONLY|O_CLOEXEC, 0);
pfd = open(_PATH_MASTERPASSWD, O_RDONLY|O_CLOEXEC);
if (pfd == -1)
pw_error(_PATH_MASTERPASSWD, 1, 1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cmp.c,v 1.18 2018/03/05 16:57:37 cheloha Exp $ */
/* $OpenBSD: cmp.c,v 1.19 2021/10/24 21:24:16 deraadt Exp $ */
/* $NetBSD: cmp.c,v 1.7 1995/09/08 03:22:56 tls Exp $ */
/*
@ -87,7 +87,7 @@ main(int argc, char *argv[])
special = 1;
fd1 = 0;
file1 = "stdin";
} else if ((fd1 = open(file1, O_RDONLY, 0)) == -1)
} else if ((fd1 = open(file1, O_RDONLY)) == -1)
fatal("%s", file1);
if (strcmp(file2 = argv[1], "-") == 0) {
if (special)
@ -95,7 +95,7 @@ main(int argc, char *argv[])
special = 1;
fd2 = 0;
file2 = "stdin";
} else if ((fd2 = open(file2, O_RDONLY, 0)) == -1)
} else if ((fd2 = open(file2, O_RDONLY)) == -1)
fatal("%s", file2);
if (pledge("stdio", NULL) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: buf.c,v 1.85 2019/06/28 13:35:00 deraadt Exp $ */
/* $OpenBSD: buf.c,v 1.86 2021/10/24 21:24:16 deraadt Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@ -85,7 +85,7 @@ buf_load(const char *path)
int fd;
BUF *bp;
if ((fd = open(path, O_RDONLY, 0600)) == -1)
if ((fd = open(path, O_RDONLY)) == -1)
fatal("buf_load: failed to load '%s' : %s", path,
strerror(errno));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diff.c,v 1.163 2017/06/01 08:08:24 joris Exp $ */
/* $OpenBSD: diff.c,v 1.164 2021/10/24 21:24:16 deraadt Exp $ */
/*
* Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
@ -586,11 +586,11 @@ cvs_diff_local(struct cvs_file *cf)
}
if (fd1 == -1) {
if ((fd1 = open(CVS_PATH_DEVNULL, O_RDONLY, 0)) == -1)
if ((fd1 = open(CVS_PATH_DEVNULL, O_RDONLY)) == -1)
fatal("cannot open %s", CVS_PATH_DEVNULL);
}
if (fd2 == -1) {
if ((fd2 = open(CVS_PATH_DEVNULL, O_RDONLY, 0)) == -1)
if ((fd2 = open(CVS_PATH_DEVNULL, O_RDONLY)) == -1)
fatal("cannot open %s", CVS_PATH_DEVNULL);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: file.c,v 1.274 2020/10/19 19:51:20 naddy Exp $ */
/* $OpenBSD: file.c,v 1.275 2021/10/24 21:24:16 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@ -1010,9 +1010,9 @@ cvs_file_cmp(const char *file1, const char *file2)
ret = 0;
if ((fd1 = open(file1, O_RDONLY|O_NOFOLLOW, 0)) == -1)
if ((fd1 = open(file1, O_RDONLY|O_NOFOLLOW)) == -1)
fatal("cvs_file_cmp: open: `%s': %s", file1, strerror(errno));
if ((fd2 = open(file2, O_RDONLY|O_NOFOLLOW, 0)) == -1)
if ((fd2 = open(file2, O_RDONLY|O_NOFOLLOW)) == -1)
fatal("cvs_file_cmp: open: `%s': %s", file2, strerror(errno));
if (fstat(fd1, &stb1) == -1)
@ -1079,7 +1079,7 @@ cvs_file_copy(const char *from, const char *to)
if (cvs_noexec == 1)
return (0);
if ((src = open(from, O_RDONLY, 0)) == -1)
if ((src = open(from, O_RDONLY)) == -1)
fatal("cvs_file_copy: open: `%s': %s", from, strerror(errno));
if (fstat(src, &st) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diffreg.c,v 1.94 2021/09/01 18:16:52 halex Exp $ */
/* $OpenBSD: diffreg.c,v 1.95 2021/10/24 21:24:16 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@ -456,7 +456,7 @@ opentemp(const char *file)
if (strcmp(file, "-") == 0)
ifd = STDIN_FILENO;
else if ((ifd = open(file, O_RDONLY, 0644)) == -1)
else if ((ifd = open(file, O_RDONLY)) == -1)
return (NULL);
(void)strlcpy(tempfile, _PATH_TMP "/diff.XXXXXXXX", sizeof(tempfile));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.31 2017/01/03 21:31:16 tedu Exp $ */
/* $OpenBSD: main.c,v 1.32 2021/10/24 21:24:16 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -126,7 +126,7 @@ main(int argc, char *argv[])
err(1, NULL);
paths = paths2;
dotfd = open(".", O_RDONLY, 0);
dotfd = open(".", O_RDONLY);
exit(find_execute(find_formplan(argv), paths));
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: last.c,v 1.53 2021/07/12 15:09:19 beck Exp $ */
/* $OpenBSD: last.c,v 1.54 2021/10/24 21:24:16 deraadt Exp $ */
/* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */
/*
@ -254,7 +254,7 @@ wtmp(void)
off_t bl;
struct ttytab *T;
if ((wfd = open(file, O_RDONLY, 0)) == -1 || fstat(wfd, &stb) == -1)
if ((wfd = open(file, O_RDONLY)) == -1 || fstat(wfd, &stb) == -1)
err(1, "%s", file);
bl = (stb.st_size + sizeof(buf) - 1) / sizeof(buf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: failedlogin.c,v 1.18 2019/01/25 00:19:26 millert Exp $ */
/* $OpenBSD: failedlogin.c,v 1.19 2021/10/24 21:24:16 deraadt Exp $ */
/*
* Copyright (c) 1996 Todd C. Miller <millert@openbsd.org>
@ -55,7 +55,7 @@ log_failedlogin(uid_t uid, char *host, char *name, char *tty)
int fd;
/* Add O_CREAT if you want to create failedlogin if it doesn't exist */
if ((fd = open(_PATH_FAILEDLOGIN, O_RDWR, S_IRUSR|S_IWUSR)) >= 0) {
if ((fd = open(_PATH_FAILEDLOGIN, O_RDWR)) >= 0) {
(void)lseek(fd, (off_t)uid * sizeof(failedlogin), SEEK_SET);
/* Read in last bad login so can get the count */
@ -95,7 +95,7 @@ check_failedlogin(uid_t uid)
(void)memset((void *)&failedlogin, 0, sizeof(failedlogin));
if ((fd = open(_PATH_FAILEDLOGIN, O_RDWR, 0)) >= 0) {
if ((fd = open(_PATH_FAILEDLOGIN, O_RDWR)) >= 0) {
(void)lseek(fd, (off_t)uid * sizeof(failedlogin), SEEK_SET);
if (read(fd, (char *)&failedlogin, sizeof(failedlogin)) ==
sizeof(failedlogin) && failedlogin.count > 0 ) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: login.c,v 1.72 2019/12/04 09:51:07 deraadt Exp $ */
/* $OpenBSD: login.c,v 1.73 2021/10/24 21:24:16 deraadt Exp $ */
/* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */
/*-
@ -800,7 +800,7 @@ motd(void)
motd = login_getcapstr(lc, "welcome", _PATH_MOTDFILE, _PATH_MOTDFILE);
if ((fd = open(motd, O_RDONLY, 0)) == -1)
if ((fd = open(motd, O_RDONLY)) == -1)
return;
memset(&sa, 0, sizeof(sa));
@ -843,7 +843,7 @@ dolastlog(int quiet)
off_t pos;
int fd;
if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
if ((fd = open(_PATH_LASTLOG, O_RDWR)) >= 0) {
pos = (off_t)pwd->pw_uid * sizeof(ll);
if (!quiet) {
if (pread(fd, &ll, sizeof(ll), pos) == sizeof(ll) &&

View File

@ -1,4 +1,4 @@
/* $OpenBSD: look.c,v 1.24 2021/07/12 15:09:20 beck Exp $ */
/* $OpenBSD: look.c,v 1.25 2021/10/24 21:24:16 deraadt Exp $ */
/* $NetBSD: look.c,v 1.7 1995/08/31 22:41:02 jtc Exp $ */
/*-
@ -118,7 +118,7 @@ main(int argc, char *argv[])
if (termchar != '\0' && (p = strchr(string, termchar)) != NULL)
*++p = '\0';
if ((fd = open(file, O_RDONLY, 0)) == -1 || fstat(fd, &sb) == -1)
if ((fd = open(file, O_RDONLY)) == -1 || fstat(fd, &sb) == -1)
err(2, "%s", file);
if (sb.st_size > SIZE_MAX)
errc(2, EFBIG, "%s", file);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: lex.c,v 1.41 2019/06/28 13:35:01 deraadt Exp $ */
/* $OpenBSD: lex.c,v 1.42 2021/10/24 21:24:16 deraadt Exp $ */
/* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */
/*
@ -108,7 +108,7 @@ setfile(char *name)
* and set pointers.
*/
readonly = 0;
if ((i = open(name, O_WRONLY, 0)) == -1)
if ((i = open(name, O_WRONLY)) == -1)
readonly++;
else
(void)close(i);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cgi.c,v 1.114 2021/08/19 15:21:32 schwarze Exp $ */
/* $OpenBSD: cgi.c,v 1.115 2021/10/24 21:24:16 deraadt Exp $ */
/*
* Copyright (c) 2014-2019, 2021 Ingo Schwarze <schwarze@usta.de>
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
@ -875,7 +875,7 @@ resp_format(const struct req *req, const char *file)
int fd;
int usepath;
if (-1 == (fd = open(file, O_RDONLY, 0))) {
if (-1 == (fd = open(file, O_RDONLY))) {
puts("<p>You specified an invalid manual file.</p>");
return;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mandocdb.c,v 1.217 2021/08/19 16:55:24 schwarze Exp $ */
/* $OpenBSD: mandocdb.c,v 1.218 2021/10/24 21:24:16 deraadt Exp $ */
/*
* Copyright (c) 2011-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
@ -2210,11 +2210,11 @@ dbwrite(struct dba *dba)
say(tfn, "&dba_write");
goto err;
}
if ((fd1 = open(MANDOC_DB, O_RDONLY, 0)) == -1) {
if ((fd1 = open(MANDOC_DB, O_RDONLY)) == -1) {
say(MANDOC_DB, "&open");
goto err;
}
if ((fd2 = open(tfn, O_RDONLY, 0)) == -1) {
if ((fd2 = open(tfn, O_RDONLY)) == -1) {
say(tfn, "&open");
goto err;
}

View File

@ -97,7 +97,7 @@ main(int argc, char **argv)
if (strcmp(ifile, "-") == 0)
ifd = STDIN_FILENO;
else {
ifd = open(ifile, O_RDONLY, 0);
ifd = open(ifile, O_RDONLY);
if (ifd == -1) {
perror(ifile);
return 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: local_passwd.c,v 1.61 2021/08/29 15:22:24 robert Exp $ */
/* $OpenBSD: local_passwd.c,v 1.62 2021/10/24 21:24:17 deraadt Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -150,7 +150,7 @@ local_passwd(char *uname, int authenticated)
}
if (i >= 4)
fputc('\n', stderr);
pfd = open(_PATH_MASTERPASSWD, O_RDONLY | O_CLOEXEC, 0);
pfd = open(_PATH_MASTERPASSWD, O_RDONLY | O_CLOEXEC);
if (pfd == -1)
pw_error(_PATH_MASTERPASSWD, 1, 1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.45 2019/12/02 22:17:32 jca Exp $ */
/* $OpenBSD: util.c,v 1.46 2021/10/24 21:24:17 deraadt Exp $ */
/*
* patch - a program to apply diffs to original files
@ -157,7 +157,7 @@ copy_file(const char *from, const char *to)
tofd = open(to, O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (tofd == -1)
return -1;
fromfd = open(from, O_RDONLY, 0);
fromfd = open(from, O_RDONLY);
if (fromfd == -1)
pfatal("internal error, can't reopen %s", from);
while ((i = read(fromfd, buf, bufsz)) > 0)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: buf.c,v 1.28 2019/06/28 13:35:03 deraadt Exp $ */
/* $OpenBSD: buf.c,v 1.29 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@ -94,7 +94,7 @@ buf_load(const char *path)
buf = NULL;
if ((fd = open(path, O_RDONLY, 0600)) == -1)
if ((fd = open(path, O_RDONLY)) == -1)
goto out;
if (fstat(fd, &st) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: isexec.c,v 1.12 2019/06/28 13:35:03 deraadt Exp $ */
/* $OpenBSD: isexec.c,v 1.13 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@ -52,7 +52,7 @@ isexec(char *file, struct stat *statp)
!(statp->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
return(FALSE);
if ((fd = open(file, O_RDONLY, 0)) == -1)
if ((fd = open(file, O_RDONLY)) == -1)
return(FALSE);
r = read(fd, &hdr, sizeof(hdr)) == sizeof(hdr) &&

View File

@ -1,4 +1,4 @@
/* $OpenBSD: copy.c,v 1.1 2021/10/22 11:10:34 claudio Exp $ */
/* $OpenBSD: copy.c,v 1.2 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
*
@ -67,11 +67,11 @@ copy_file(int rootfd, const char *basedir, const struct flist *f)
{
int fromfd, tofd, dfd;
dfd = openat(rootfd, basedir, O_RDONLY | O_DIRECTORY, 0);
dfd = openat(rootfd, basedir, O_RDONLY | O_DIRECTORY);
if (dfd == -1)
err(ERR_FILE_IO, "%s: openat", basedir);
fromfd = openat(dfd, f->path, O_RDONLY | O_NOFOLLOW, 0);
fromfd = openat(dfd, f->path, O_RDONLY | O_NOFOLLOW);
if (fromfd == -1)
err(ERR_FILE_IO, "%s/%s: openat", basedir, f->path);
close(dfd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: downloader.c,v 1.22 2021/06/30 13:10:04 claudio Exp $ */
/* $OpenBSD: downloader.c,v 1.23 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -350,7 +350,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
p->state = DOWNLOAD_READ_LOCAL;
f = &p->fl[idx];
p->ofd = openat(p->rootfd, f->path, O_RDONLY | O_NONBLOCK, 0);
p->ofd = openat(p->rootfd, f->path, O_RDONLY | O_NONBLOCK);
if (p->ofd == -1 && errno != ENOENT) {
ERR("%s: openat", f->path);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: receiver.c,v 1.30 2021/10/22 11:10:34 claudio Exp $ */
/* $OpenBSD: receiver.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@ -267,7 +267,7 @@ rsync_receiver(struct sess *sess, int fdin, int fdout, const char *root)
oumask = umask(0);
if (!sess->opts->dry_run) {
dfd = open(root, O_RDONLY | O_DIRECTORY, 0);
dfd = open(root, O_RDONLY | O_DIRECTORY);
if (dfd == -1)
err(ERR_FILE_IO, "%s: open", root);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uploader.c,v 1.30 2021/10/22 11:10:34 claudio Exp $ */
/* $OpenBSD: uploader.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2019 Florian Obser <florian@openbsd.org>
@ -736,7 +736,7 @@ pre_file(const struct upload *p, int *filefd, off_t *size,
const char *root = sess->opts->basedir[i];
int dfd, x;
dfd = openat(p->rootfd, root, O_RDONLY | O_DIRECTORY, 0);
dfd = openat(p->rootfd, root, O_RDONLY | O_DIRECTORY);
if (dfd == -1)
err(ERR_FILE_IO, "%s: openat", root);
x = check_file(dfd, f, &st);
@ -771,7 +771,7 @@ pre_file(const struct upload *p, int *filefd, off_t *size,
}
*size = st.st_size;
*filefd = openat(p->rootfd, f->path, O_RDONLY | O_NOFOLLOW, 0);
*filefd = openat(p->rootfd, f->path, O_RDONLY | O_NOFOLLOW);
if (*filefd == -1 && errno != ENOENT) {
ERR("%s: openat", f->path);
return -1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sdiff.c,v 1.38 2021/07/12 15:09:20 beck Exp $ */
/* $OpenBSD: sdiff.c,v 1.39 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Written by Raymond Lai <ray@cyth.net>.
@ -102,7 +102,7 @@ mktmpcpy(const char *source_file)
char *target_file;
/* Open input and output. */
ifd = open(source_file, O_RDONLY, 0);
ifd = open(source_file, O_RDONLY);
/* File was opened successfully. */
if (ifd != -1) {
if (fstat(ifd, &sb) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: spellprog.c,v 1.14 2019/03/10 20:45:11 schwarze Exp $ */
/* $OpenBSD: spellprog.c,v 1.15 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 1991, 1993
@ -281,7 +281,7 @@ main(int argc, char **argv)
if ((wlists = calloc(sizeof(struct wlist), (argc + 1))) == NULL)
err(1, "malloc");
for (i = 0; argc--; i++) {
wlists[i].fd = open(argv[i], O_RDONLY, 0);
wlists[i].fd = open(argv[i], O_RDONLY);
if (wlists[i].fd == -1 || fstat(wlists[i].fd, &sb) != 0)
err(1, "%s", argv[i]);
if (sb.st_size > SIZE_MAX)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: split.c,v 1.21 2015/12/31 16:13:01 millert Exp $ */
/* $OpenBSD: split.c,v 1.22 2021/10/24 21:24:17 deraadt Exp $ */
/* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */
/*
@ -133,7 +133,7 @@ main(int argc, char *argv[])
if (*argv != NULL)
if (ifd == -1) { /* Input file. */
if ((ifd = open(*argv, O_RDONLY, 0)) < 0)
if ((ifd = open(*argv, O_RDONLY)) < 0)
err(1, "%s", *argv);
++argv;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: scp.c,v 1.240 2021/10/15 14:46:46 deraadt Exp $ */
/* $OpenBSD: scp.c,v 1.241 2021/10/24 21:24:17 deraadt Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@ -1294,7 +1294,7 @@ source(int argc, char **argv)
len = strlen(name);
while (len > 1 && name[len-1] == '/')
name[--len] = '\0';
if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) == -1)
if ((fd = open(name, O_RDONLY|O_NONBLOCK)) == -1)
goto syserr;
if (strchr(name, '\n') != NULL) {
strnvis(encname, name, sizeof(encname), VIS_NL);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sftp-client.c,v 1.155 2021/09/03 05:12:25 dtucker Exp $ */
/* $OpenBSD: sftp-client.c,v 1.156 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@ -1816,7 +1816,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
TAILQ_INIT(&acks);
if ((local_fd = open(local_path, O_RDONLY, 0)) == -1) {
if ((local_fd = open(local_path, O_RDONLY)) == -1) {
error("Couldn't open local file \"%s\" for reading: %s",
local_path, strerror(errno));
return(-1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cmd-pipe-pane.c,v 1.58 2021/08/21 10:22:39 nicm Exp $ */
/* $OpenBSD: cmd-pipe-pane.c,v 1.59 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@ -131,7 +131,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
sigprocmask(SIG_SETMASK, &oldset, NULL);
close(pipe_fd[0]);
null_fd = open(_PATH_DEVNULL, O_WRONLY, 0);
null_fd = open(_PATH_DEVNULL, O_WRONLY);
if (out) {
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
_exit(1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: job.c,v 1.65 2021/10/11 10:55:30 nicm Exp $ */
/* $OpenBSD: job.c,v 1.66 2021/10/24 21:24:17 deraadt Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@ -142,7 +142,7 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e, struct sessio
close(out[1]);
close(out[0]);
nullfd = open(_PATH_DEVNULL, O_RDWR, 0);
nullfd = open(_PATH_DEVNULL, O_RDWR);
if (nullfd == -1)
fatal("open failed");
if (dup2(nullfd, STDERR_FILENO) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cl_main.c,v 1.35 2021/09/02 11:19:02 schwarze Exp $ */
/* $OpenBSD: cl_main.c,v 1.36 2021/10/24 21:24:17 deraadt Exp $ */
/*-
* Copyright (c) 1993, 1994
@ -183,7 +183,7 @@ cl_init(GS *gp)
if (F_ISSET(clp, CL_STDIN_TTY)) {
if (tcgetattr(STDIN_FILENO, &clp->orig) == -1)
goto tcfail;
} else if ((fd = open(_PATH_TTY, O_RDONLY, 0)) != -1) {
} else if ((fd = open(_PATH_TTY, O_RDONLY)) != -1) {
if (tcgetattr(fd, &clp->orig) == -1)
tcfail: err(1, "tcgetattr");
(void)close(fd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: exf.c,v 1.46 2017/04/26 13:14:28 millert Exp $ */
/* $OpenBSD: exf.c,v 1.47 2021/10/24 21:24:17 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -977,7 +977,7 @@ file_backup(SCR *sp, char *name, char *bname)
* up.
*/
errno = 0;
if ((rfd = open(name, O_RDONLY, 0)) < 0) {
if ((rfd = open(name, O_RDONLY)) < 0) {
if (errno == ENOENT)
return (0);
estr = name;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.42 2021/01/26 18:19:43 deraadt Exp $ */
/* $OpenBSD: main.c,v 1.43 2021/10/24 21:24:17 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -578,7 +578,7 @@ attach(GS *gp)
int fd;
char ch;
if ((fd = open(_PATH_TTY, O_RDONLY, 0)) < 0) {
if ((fd = open(_PATH_TTY, O_RDONLY)) < 0) {
warn("%s", _PATH_TTY);
return;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: recover.c,v 1.30 2019/07/22 12:39:02 schwarze Exp $ */
/* $OpenBSD: recover.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */
/*-
* Copyright (c) 1993, 1994
@ -750,7 +750,7 @@ rcv_copy(SCR *sp, int wfd, char *fname)
int nr, nw, off, rfd;
char buf[8 * 1024];
if ((rfd = open(fname, O_RDONLY, 0)) == -1)
if ((rfd = open(fname, O_RDONLY)) == -1)
goto err;
while ((nr = read(rfd, buf, sizeof(buf))) > 0)
for (off = 0; nr; nr -= nw, off += nw)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ex_init.c,v 1.18 2017/04/18 01:45:35 deraadt Exp $ */
/* $OpenBSD: ex_init.c,v 1.19 2021/10/24 21:24:17 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -341,7 +341,7 @@ exrc_isok(SCR *sp, struct stat *sbp, int *fdp, char *path, int rootown,
int nf1, nf2;
char *a, *b, buf[PATH_MAX];
if ((*fdp = open(path, O_RDONLY, 0)) < 0) {
if ((*fdp = open(path, O_RDONLY)) < 0) {
if (errno == ENOENT)
/* This is the only case where ex_exrc()
* should silently try the next file, for

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ex_source.c,v 1.10 2015/12/07 20:39:19 mmcc Exp $ */
/* $OpenBSD: ex_source.c,v 1.11 2021/10/24 21:24:17 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -93,7 +93,7 @@ ex_source(SCR *sp, EXCMD *cmdp)
int fd;
name = cmdp->argv[0]->bp;
if ((fd = open(name, O_RDONLY, 0)) >= 0)
if ((fd = open(name, O_RDONLY)) >= 0)
return (ex_sourcefd(sp, cmdp, fd));
msgq_str(sp, M_SYSERR, name, "%s");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ex_tag.c,v 1.25 2017/04/18 01:45:35 deraadt Exp $ */
/* $OpenBSD: ex_tag.c,v 1.26 2021/10/24 21:24:17 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -991,7 +991,7 @@ ctag_sfile(SCR *sp, TAGF *tfp, TAGQ *tqp, char *tname)
int fd, i, nf1, nf2;
char *back, *cname, *dname, *front, *map, *name, *p, *search, *t;
if ((fd = open(tfp->name, O_RDONLY, 0)) < 0) {
if ((fd = open(tfp->name, O_RDONLY)) < 0) {
tfp->errnum = errno;
return (1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ttymsg.c,v 1.19 2019/06/28 13:35:05 deraadt Exp $ */
/* $OpenBSD: ttymsg.c,v 1.20 2021/10/24 21:24:17 deraadt Exp $ */
/* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */
/*
@ -91,7 +91,7 @@ ttymsg(iov, iovcnt, line, tmout)
* open will fail on slip lines or exclusive-use lines
* if not running as root; not an error.
*/
if ((fd = open(device, O_WRONLY|O_NONBLOCK, 0)) == -1) {
if ((fd = open(device, O_WRONLY|O_NONBLOCK)) == -1) {
if (errno == EBUSY || errno == EACCES)
return (NULL);
(void) snprintf(errbuf, sizeof(errbuf),

View File

@ -1,4 +1,4 @@
/* $OpenBSD: wc.c,v 1.26 2019/06/28 13:35:05 deraadt Exp $ */
/* $OpenBSD: wc.c,v 1.27 2021/10/24 21:24:18 deraadt Exp $ */
/*
* Copyright (c) 1980, 1987, 1991, 1993
@ -132,7 +132,7 @@ cnt(char *file)
linect = wordct = charct = 0;
stream = NULL;
if (file) {
if ((fd = open(file, O_RDONLY, 0)) == -1) {
if ((fd = open(file, O_RDONLY)) == -1) {
warn("%s", file);
rval = 1;
return;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: write.c,v 1.35 2019/06/28 13:35:05 deraadt Exp $ */
/* $OpenBSD: write.c,v 1.36 2021/10/24 21:24:18 deraadt Exp $ */
/* $NetBSD: write.c,v 1.5 1995/08/31 21:48:32 jtc Exp $ */
/*
@ -236,7 +236,7 @@ do_write(char *tty, char *mytty, uid_t myuid)
login = user_from_uid(myuid, 0);
(void)snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty);
fd = open(path, O_WRONLY, 0666);
fd = open(path, O_WRONLY);
if (fd == -1)
err(1, "open %s", path);
fflush(stdout);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: xinstall.c,v 1.74 2020/04/07 09:40:09 espie Exp $ */
/* $OpenBSD: xinstall.c,v 1.75 2021/10/24 21:24:18 deraadt Exp $ */
/* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */
/*
@ -256,7 +256,7 @@ install(char *from_name, char *to_name, u_long fset, u_int flags)
}
if (!devnull) {
if ((from_fd = open(from_name, O_RDONLY, 0)) == -1)
if ((from_fd = open(from_name, O_RDONLY)) == -1)
err(1, "%s", from_name);
}
@ -276,7 +276,7 @@ install(char *from_name, char *to_name, u_long fset, u_int flags)
* that does not work in-place -- like gnu binutils strip.
*/
close(to_fd);
if ((to_fd = open(tempfile, O_RDONLY, 0)) == -1)
if ((to_fd = open(tempfile, O_RDONLY)) == -1)
err(1, "stripping %s", to_name);
}
@ -288,7 +288,7 @@ install(char *from_name, char *to_name, u_long fset, u_int flags)
struct stat temp_sb;
/* Re-open to_fd using the real target name. */
if ((to_fd = open(to_name, O_RDONLY, 0)) == -1)
if ((to_fd = open(to_name, O_RDONLY)) == -1)
err(1, "%s", to_name);
if (fstat(temp_fd, &temp_sb)) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: exec_elf.c,v 1.17 2019/06/28 13:32:47 deraadt Exp $ */
/* $OpenBSD: exec_elf.c,v 1.18 2021/10/24 21:24:18 deraadt Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@ -97,7 +97,7 @@ loadkernel(char *file)
{
int fd;
if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) == -1)
if ((fd = open(file, O_RDONLY | O_EXLOCK)) == -1)
err(1, "%s", file);
if (read(fd, (char *)&elf_ex, sizeof(elf_ex)) != sizeof(elf_ex))

View File

@ -1,4 +1,4 @@
/* $OpenBSD: atrun.c,v 1.52 2019/10/20 13:33:30 millert Exp $ */
/* $OpenBSD: atrun.c,v 1.53 2021/10/24 21:24:18 deraadt Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <millert@openbsd.org>
@ -336,7 +336,7 @@ run_job(const atjob *job, int dfd, const char *atfile)
char *nargv[2], *nenvp[1];
/* Open the file and unlink it so we don't try running it again. */
if ((fd = openat(dfd, atfile, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1) {
if ((fd = openat(dfd, atfile, O_RDONLY|O_NONBLOCK|O_NOFOLLOW)) == -1) {
syslog(LOG_ERR, "(CRON) CAN'T OPEN (%s)", atfile);
return;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: crunchgen.c,v 1.23 2021/03/10 22:52:28 jsg Exp $ */
/* $OpenBSD: crunchgen.c,v 1.24 2021/10/24 21:24:18 deraadt Exp $ */
/*
* Copyright (c) 1994 University of Maryland
@ -680,7 +680,7 @@ fillin_program_objs(prog_t * p, char *path)
fprintf(f, "crunchgen_objs:\n\t@echo 'OBJS= '${OBJS}\n");
fclose(f);
if ((dotfd = open(".", O_RDONLY, 0)) == -1 ||
if ((dotfd = open(".", O_RDONLY)) == -1 ||
getcwd(cwd, sizeof(cwd)) == NULL) {
perror("get cwd");
goterror = 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pfutils.c,v 1.22 2021/07/12 15:09:20 beck Exp $ */
/* $OpenBSD: pfutils.c,v 1.23 2021/10/24 21:24:18 deraadt Exp $ */
/*
* Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org>
*
@ -52,7 +52,7 @@ pftable_handler()
struct pollfd pfd[1];
int l, r, fd, nfds;
if ((fd = open(_PATH_DEV_PF, O_RDWR|O_NOFOLLOW, 0660)) == -1)
if ((fd = open(_PATH_DEV_PF, O_RDWR|O_NOFOLLOW)) == -1)
fatal("can't open pf device");
if (setgroups(1, &pw->pw_gid) ||

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dhcrelay.c,v 1.65 2019/08/06 11:07:37 krw Exp $ */
/* $OpenBSD: dhcrelay.c,v 1.66 2021/10/24 21:24:18 deraadt Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org>
@ -210,7 +210,7 @@ main(int argc, char *argv[])
}
if (daemonize) {
devnull = open(_PATH_DEVNULL, O_RDWR, 0);
devnull = open(_PATH_DEVNULL, O_RDWR);
if (devnull == -1)
fatal("open(%s)", _PATH_DEVNULL);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dhcrelay6.c,v 1.3 2019/08/06 11:07:37 krw Exp $ */
/* $OpenBSD: dhcrelay6.c,v 1.4 2021/10/24 21:24:18 deraadt Exp $ */
/*
* Copyright (c) 2017 Rafael Zalamena <rzalamena@openbsd.org>
@ -236,7 +236,7 @@ main(int argc, char *argv[])
}
if (daemonize) {
devnull = open(_PATH_DEVNULL, O_RDWR, 0);
devnull = open(_PATH_DEVNULL, O_RDWR);
if (devnull == -1)
fatal("open(%s)", _PATH_DEVNULL);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ophandlers.c,v 1.15 2019/06/28 13:32:47 deraadt Exp $ */
/* $OpenBSD: ophandlers.c,v 1.16 2021/10/24 21:24:18 deraadt Exp $ */
/* $NetBSD: ophandlers.c,v 1.2 1996/02/28 01:13:30 thorpej Exp $ */
/*-
@ -79,7 +79,7 @@ op_handler(char *keyword, char *arg)
char opio_buf[BUFSIZE];
int fd, optnode;
if ((fd = open(path_openprom, arg ? O_RDWR : O_RDONLY, 0640)) == -1)
if ((fd = open(path_openprom, arg ? O_RDWR : O_RDONLY)) == -1)
BARF(path_openprom, strerror(errno));
/* Check to see if it's a special-case keyword. */
@ -178,7 +178,7 @@ op_dump(void)
char buf1[BUFSIZE], buf2[BUFSIZE], buf3[BUFSIZE], buf4[BUFSIZE];
int fd, optnode;
if ((fd = open(path_openprom, O_RDONLY, 0640)) == -1)
if ((fd = open(path_openprom, O_RDONLY)) == -1)
err(1, "open: %s", path_openprom);
if (ioctl(fd, OPIOCGETOPTNODE, (char *)&optnode) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: optree.c,v 1.10 2019/06/28 13:32:47 deraadt Exp $ */
/* $OpenBSD: optree.c,v 1.11 2021/10/24 21:24:18 deraadt Exp $ */
/*
* Copyright (c) 2007 Federico G. Schwindt <fgsch@openbsd.org>
@ -177,7 +177,7 @@ op_tree(void)
{
int fd;
if ((fd = open(path_openprom, O_RDONLY, 0640)) == -1)
if ((fd = open(path_openprom, O_RDONLY)) == -1)
err(1, "open: %s", path_openprom);
op_nodes(fd, 0, 0);
(void)close(fd);

Some files were not shown because too many files have changed in this diff Show More