diff mbox series

[uclibc-ng-devel] openpty/forkpty: use const for termios and winsize arguments

Message ID 20250603054350.12533-1-marcus.haehnel@kernkonzept.com
State Accepted
Headers show
Series [uclibc-ng-devel] openpty/forkpty: use const for termios and winsize arguments | expand

Commit Message

Marcus Haehnel June 3, 2025, 5:43 a.m. UTC
The termios and winsize arguments are const as per the POSIX standard,
and also uclibc and musl define them as such. Adapt the uclibc-ng
definitions and declarations accordingly to improve compatibility.

Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
---
 include/pty.h     | 6 ++++--
 libutil/forkpty.c | 3 ++-
 libutil/openpty.c | 4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)

Comments

Waldemar Brodkorb July 1, 2025, 2:42 p.m. UTC | #1
Hi Marcus,

patch is pushed, thanks
 Waldemar

Marcus Haehnel wrote,

> The termios and winsize arguments are const as per the POSIX standard,
> and also uclibc and musl define them as such. Adapt the uclibc-ng
> definitions and declarations accordingly to improve compatibility.
> 
> Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
> ---
>  include/pty.h     | 6 ++++--
>  libutil/forkpty.c | 3 ++-
>  libutil/openpty.c | 4 ++--
>  3 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/include/pty.h b/include/pty.h
> index f23a260ae..609ac2459 100644
> --- a/include/pty.h
> +++ b/include/pty.h
> @@ -31,13 +31,15 @@ __BEGIN_DECLS
>     attributes according to TERMP and WINP and return handles for both
>     ends in AMASTER and ASLAVE.  */
>  extern int openpty (int *__amaster, int *__aslave, char *__name,
> -		    struct termios *__termp, struct winsize *__winp) __THROW;
> +		    const struct termios *__termp,
> +		    const struct winsize *__winp) __THROW;
>  libutil_hidden_proto(openpty)
>  
>  /* Create child process and establish the slave pseudo terminal as the
>     child's controlling terminal.  */
>  extern int forkpty (int *__amaster, char *__name,
> -		    struct termios *__termp, struct winsize *__winp) __THROW;
> +		    const struct termios *__termp,
> +		    const struct winsize *__winp) __THROW;
>  
>  __END_DECLS
>  
> diff --git a/libutil/forkpty.c b/libutil/forkpty.c
> index 24643330c..7e42d1a33 100644
> --- a/libutil/forkpty.c
> +++ b/libutil/forkpty.c
> @@ -23,7 +23,8 @@
>  #include <pty.h>
>  
>  int
> -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 master, slave, pid;
>  
> diff --git a/libutil/openpty.c b/libutil/openpty.c
> index 848dc8d38..e14cbc57d 100644
> --- a/libutil/openpty.c
> +++ b/libutil/openpty.c
> @@ -85,8 +85,8 @@ pts_name (int fd, char **pts, size_t buf_len)
>     according to TERMP and WINP.  Return handles for both ends in
>     AMASTER and ASLAVE, and return the name of the slave end in NAME.  */
>  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)
>  {
>  #if 0
>  #ifdef PATH_MAX
> -- 
> 2.47.1
> 
> _______________________________________________
> devel mailing list -- devel@uclibc-ng.org
> To unsubscribe send an email to devel-leave@uclibc-ng.org
>
diff mbox series

Patch

diff --git a/include/pty.h b/include/pty.h
index f23a260ae..609ac2459 100644
--- a/include/pty.h
+++ b/include/pty.h
@@ -31,13 +31,15 @@  __BEGIN_DECLS
    attributes according to TERMP and WINP and return handles for both
    ends in AMASTER and ASLAVE.  */
 extern int openpty (int *__amaster, int *__aslave, char *__name,
-		    struct termios *__termp, struct winsize *__winp) __THROW;
+		    const struct termios *__termp,
+		    const struct winsize *__winp) __THROW;
 libutil_hidden_proto(openpty)
 
 /* Create child process and establish the slave pseudo terminal as the
    child's controlling terminal.  */
 extern int forkpty (int *__amaster, char *__name,
-		    struct termios *__termp, struct winsize *__winp) __THROW;
+		    const struct termios *__termp,
+		    const struct winsize *__winp) __THROW;
 
 __END_DECLS
 
diff --git a/libutil/forkpty.c b/libutil/forkpty.c
index 24643330c..7e42d1a33 100644
--- a/libutil/forkpty.c
+++ b/libutil/forkpty.c
@@ -23,7 +23,8 @@ 
 #include <pty.h>
 
 int
-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 master, slave, pid;
 
diff --git a/libutil/openpty.c b/libutil/openpty.c
index 848dc8d38..e14cbc57d 100644
--- a/libutil/openpty.c
+++ b/libutil/openpty.c
@@ -85,8 +85,8 @@  pts_name (int fd, char **pts, size_t buf_len)
    according to TERMP and WINP.  Return handles for both ends in
    AMASTER and ASLAVE, and return the name of the slave end in NAME.  */
 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)
 {
 #if 0
 #ifdef PATH_MAX