On Thu, 2025-06-26 at 17:08 +0200, Waldemar Brodkorb wrote:
> Hi Marcus,
> 
> can you double check if this patch applies when the previous patch
> you sent is applied?
> It seems either one can be applied cleanly with git am, but not
> both.

True, they both touch code close to each other and thus modify the context. 
Resent this one such that it is based on the
other openpty change.

Best,

- Marcus

> best regards
>  Waldemar
> 
> Marcus Haehnel wrote,
> 
> > The use of ptsname_r instead of the custom pts_name seems to have proven
> > in the field.
> > 
> > Signed-off-by: Marcus Haehnel <marcus.haeh...@kernkonzept.com>
> > ---
> >  libutil/openpty.c | 76 -----------------------------------------------
> >  1 file changed, 76 deletions(-)
> > 
> > diff --git a/libutil/openpty.c b/libutil/openpty.c
> > index 848dc8d38..0a8b04317 100644
> > --- a/libutil/openpty.c
> > +++ b/libutil/openpty.c
> > @@ -26,61 +26,6 @@
> >  #include <unistd.h>
> >  #include <sys/types.h>
> >  
> > -/* BCS: the following function is, IMO, overkill */
> > -#if 0
> > -/* Return the result of ptsname_r in the buffer pointed to by PTS,
> > -   which should be of length BUF_LEN.  If it is too long to fit in
> > -   this buffer, a sufficiently long buffer is allocated using malloc,
> > -   and returned in PTS.  0 is returned upon success, -1 otherwise.  */
> > -static int
> > -pts_name (int fd, char **pts, size_t buf_len)
> > -{
> > -  int rv;
> > -  char *buf = *pts;
> > -
> > -  for (;;)
> > -    {
> > -      char *new_buf;
> > -
> > -      if (buf_len)
> > -   {
> > -     rv = ptsname_r (fd, buf, buf_len);
> > -
> > -     if (rv != 0 || memchr (buf, '\0', buf_len))
> > -       /* We either got an error, or we succeeded and the
> > -          returned name fit in the buffer.  */
> > -       break;
> > -
> > -     /* Try again with a longer buffer.  */
> > -     buf_len += buf_len;   /* Double it */
> > -   }
> > -      else
> > -   /* No initial buffer; start out by mallocing one.  */
> > -   buf_len = 128;          /* First time guess.  */
> > -
> > -      if (buf != *pts)
> > -   /* We've already malloced another buffer at least once.  */
> > -   new_buf = realloc (buf, buf_len);
> > -      else
> > -   new_buf = malloc (buf_len);
> > -      if (! new_buf)
> > -   {
> > -     rv = -1;
> > -     __set_errno (ENOMEM);
> > -     break;
> > -   }
> > -      buf = new_buf;
> > -    }
> > -
> > -  if (rv == 0)
> > -    *pts = buf;            /* Return buffer to the user.  */
> > -  else if (buf != *pts)
> > -    free (buf);            /* Free what we malloced when returning an 
> > error.  */
> > -
> > -  return rv;
> > -}
> > -#endif
> > -
> >  /* Create pseudo tty master slave pair and set terminal attributes
> >     according to TERMP and WINP.  Return handles for both ends in
> >     AMASTER and ASLAVE, and return the name of the slave end in NAME.  */
> > @@ -88,19 +33,10 @@ int
> >  openpty (int *amaster, int *aslave, char *name, struct termios *termp,
> >      struct winsize *winp)
> >  {
> > -#if 0
> > -#ifdef PATH_MAX
> > -  char _buf[PATH_MAX];
> > -#else
> > -  char _buf[512];
> > -#endif
> > -  char *buf = _buf;
> > -#else
> >  #ifdef PATH_MAX
> >    char buf[PATH_MAX];
> >  #else
> >    char buf[512];
> > -#endif
> >  #endif
> >    int master, slave;
> >  
> > @@ -114,20 +50,12 @@ openpty (int *amaster, int *aslave, char *name, struct 
> > termios *termp,
> >    if (unlockpt (master))
> >      goto fail;
> >  
> > -#if 0
> > -  if (pts_name (master, &buf, sizeof (_buf)))
> > -#else
> >    if (ptsname_r (master, buf, sizeof buf))
> > -#endif
> >      goto fail;
> >  
> >    slave = open (buf, O_RDWR | O_NOCTTY);
> >    if (slave == -1)
> >      {
> > -#if 0
> > -      if (buf != _buf)
> > -   free (buf);
> > -#endif
> >        goto fail;
> >      }
> >  
> > @@ -142,10 +70,6 @@ openpty (int *amaster, int *aslave, char *name, struct 
> > termios *termp,
> >    if (name != NULL)
> >      strcpy (name, buf);
> >  
> > -#if 0
> > -  if (buf != _buf)
> > -    free (buf);
> > -#endif
> >    return 0;
> >  
> >   fail:
> > -- 
> > 2.47.1
> > 
> > _______________________________________________
> > devel mailing list -- devel@uclibc-ng.org
> > To unsubscribe send an email to devel-le...@uclibc-ng.org
> > 
> _______________________________________________
> devel mailing list -- devel@uclibc-ng.org
> To unsubscribe send an email to devel-le...@uclibc-ng.org

-- 
+++ Register now for our workshop “Get to know L4Re in 3 days” on October 
28–30. Learn to design and deploy secure system
architectures for your product with L4Re: 
https://www.kernkonzept.com/workshop-getting-started-with-l4re/ +++

---

Kernkonzept GmbH
Sitz: Dresden
HRB 31129
Geschäftsführer: Dr.-Ing. Michael Hohmuth




Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
devel mailing list -- devel@uclibc-ng.org
To unsubscribe send an email to devel-le...@uclibc-ng.org

Reply via email to