From 78fa49ead5f0889b599940410aaa89ed00d2943e Mon Sep 17 00:00:00 2001 From: millert Date: Wed, 20 Apr 2022 14:00:19 +0000 Subject: [PATCH] Make the termp and winp arguments for openpty, et al. const. This matches the prototypes in glibc and musl libc. From Matthew Martin. OK tb@ --- lib/libutil/openpty.3 | 12 ++++++------ lib/libutil/pty.c | 15 ++++++++------- lib/libutil/util.h | 14 ++++++++------ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/libutil/openpty.3 b/lib/libutil/openpty.3 index e0c82e00c53..2610e77647c 100644 --- a/lib/libutil/openpty.3 +++ b/lib/libutil/openpty.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: openpty.3,v 1.19 2017/04/20 19:30:42 jmc Exp $ +.\" $OpenBSD: openpty.3,v 1.20 2022/04/20 14:00:19 millert Exp $ .\" Copyright (c) 1995 .\" The Regents of the University of California. All rights reserved. .\" @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: April 20 2017 $ +.Dd $Mdocdate: April 20 2022 $ .Dt OPENPTY 3 .Os .Sh NAME @@ -47,15 +47,15 @@ .Ft int .Fn getptmfd "void" .Ft int -.Fn openpty "int *amaster" "int *aslave" "char *name" "struct termios *termp" "struct winsize *winp" +.Fn openpty "int *amaster" "int *aslave" "char *name" "const struct termios *termp" "const struct winsize *winp" .Ft int -.Fn fdopenpty "int ptmfd" "int *amaster" "int *aslave" "char *name" "struct termios *termp" "struct winsize *winp" +.Fn fdopenpty "int ptmfd" "int *amaster" "int *aslave" "char *name" "const struct termios *termp" "const struct winsize *winp" .Ft int .Fn login_tty "int fd" .Ft pid_t -.Fn forkpty "int *amaster" "char *name" "struct termios *termp" "struct winsize *winp" +.Fn forkpty "int *amaster" "char *name" "const struct termios *termp" "const struct winsize *winp" .Ft pid_t -.Fn fdforkpty "int ptmfd" "int *amaster" "char *name" "struct termios *termp" "struct winsize *winp" +.Fn fdforkpty "int ptmfd" "int *amaster" "char *name" "const struct termios *termp" "const struct winsize *winp" .Sh DESCRIPTION The .Fn openpty , diff --git a/lib/libutil/pty.c b/lib/libutil/pty.c index c796acb5041..0f2c2c1c42e 100644 --- a/lib/libutil/pty.c +++ b/lib/libutil/pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pty.c,v 1.21 2017/04/20 17:48:30 nicm Exp $ */ +/* $OpenBSD: pty.c,v 1.22 2022/04/20 14:00:19 millert Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -50,8 +50,8 @@ getptmfd(void) } int -openpty(int *amaster, int *aslave, char *name, struct termios *termp, - struct winsize *winp) +openpty(int *amaster, int *aslave, char *name, const struct termios *termp, + const struct winsize *winp) { int ptmfd; @@ -67,7 +67,7 @@ openpty(int *amaster, int *aslave, char *name, struct termios *termp, int fdopenpty(int ptmfd, int *amaster, int *aslave, char *name, - struct termios *termp, struct winsize *winp) + const struct termios *termp, const struct winsize *winp) { int master, slave; struct ptmget ptm; @@ -97,7 +97,8 @@ fdopenpty(int ptmfd, int *amaster, int *aslave, char *name, } pid_t -forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp) +forkpty(int *amaster, char *name, const struct termios *termp, + const struct winsize *winp) { int ptmfd; pid_t pid; @@ -113,8 +114,8 @@ forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp) } pid_t -fdforkpty(int ptmfd, int *amaster, char *name, struct termios *termp, - struct winsize *winp) +fdforkpty(int ptmfd, int *amaster, char *name, const struct termios *termp, + const struct winsize *winp) { int master, slave; pid_t pid; diff --git a/lib/libutil/util.h b/lib/libutil/util.h index d7aa8faed4b..dd64f478e23 100644 --- a/lib/libutil/util.h +++ b/lib/libutil/util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: util.h,v 1.36 2019/08/30 03:57:56 deraadt Exp $ */ +/* $OpenBSD: util.h,v 1.37 2022/04/20 14:00:19 millert Exp $ */ /* $NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $ */ /*- @@ -99,12 +99,14 @@ void pw_copy(int, int, const struct passwd *, const struct passwd *); int pw_scan(char *, struct passwd *, int *); void pw_error(const char *, int, int); int getptmfd(void); -int openpty(int *, int *, char *, struct termios *, struct winsize *); -int fdopenpty(int, int *, int *, char *, struct termios *, - struct winsize *); +int openpty(int *, int *, char *, const struct termios *, + const struct winsize *); +int fdopenpty(int, int *, int *, char *, const struct termios *, + const struct winsize *); int opendisk(const char *, int, char *, size_t, int); -pid_t forkpty(int *, char *, struct termios *, struct winsize *); -pid_t fdforkpty(int, int *, char *, struct termios *, struct winsize *); +pid_t forkpty(int *, char *, const struct termios *, const struct winsize *); +pid_t fdforkpty(int, int *, char *, const struct termios *, + const struct winsize *); int getmaxpartitions(void); int getrawpartition(void); void login_fbtab(const char *, uid_t, gid_t); -- 2.20.1