qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, d-tatianin@yandex-team.ru
Subject: Re: [PATCH v2 07/10] chardev/char-pty: store pty_name into PtyChardev state
Date: Fri, 5 Dec 2025 19:20:58 +0400	[thread overview]
Message-ID: <CAMxuvayOyP19mPEASBqkuiLw=CiWqWE4hocM6v9tj5pOxZtFJA@mail.gmail.com> (raw)
In-Reply-To: <20251204154235.149575-8-vsementsov@yandex-team.ru>

[-- Attachment #1: Type: text/plain, Size: 3010 bytes --]

On Thu, Dec 4, 2025 at 7:42 PM Vladimir Sementsov-Ogievskiy <
vsementsov@yandex-team.ru> wrote:

> We'll use it in following commit.
>
> Note the bonus: stop use blind strcpy().
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  chardev/char-pty.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/chardev/char-pty.c b/chardev/char-pty.c
> index 9e26e97baf..a582aa7bc7 100644
> --- a/chardev/char-pty.c
> +++ b/chardev/char-pty.c
> @@ -43,6 +43,7 @@ struct PtyChardev {
>      int connected;
>      GSource *timer_src;
>      char *path;
> +    char *pty_name;
>  };
>  typedef struct PtyChardev PtyChardev;
>
> @@ -303,7 +304,7 @@ static void cfmakeraw (struct termios *termios_p)
>  #endif
>
>  /* like openpty() but also makes it raw; return master fd */
> -static int qemu_openpty_raw(int *aslave, char *pty_name)
> +static int qemu_openpty_raw(int *aslave, char **pty_name)
>  {
>      int amaster;
>      struct termios tty;
> @@ -324,9 +325,7 @@ static int qemu_openpty_raw(int *aslave, char
> *pty_name)
>      cfmakeraw(&tty);
>      tcsetattr(*aslave, TCSAFLUSH, &tty);
>
> -    if (pty_name) {
> -        strcpy(pty_name, q_ptsname(amaster));
> -    }
> +    *pty_name = g_strdup(q_ptsname(amaster));
>
>      return amaster;
>  }
> @@ -335,11 +334,12 @@ static bool pty_chr_open(Chardev *chr,
> ChardevBackend *backend, Error **errp)
>  {
>      PtyChardev *s;
>      int master_fd, slave_fd;
> -    char pty_name[PATH_MAX];
>      char *name;
>      char *path = backend->u.pty.data->path;
>
> -    master_fd = qemu_openpty_raw(&slave_fd, pty_name);
> +    s = PTY_CHARDEV(chr);
> +
> +    master_fd = qemu_openpty_raw(&slave_fd, &s->pty_name);
>      if (master_fd < 0) {
>          error_setg_errno(errp, errno, "Failed to create PTY");
>          return false;
> @@ -351,11 +351,10 @@ static bool pty_chr_open(Chardev *chr,
> ChardevBackend *backend, Error **errp)
>          return false;
>      }
>
> -    chr->filename = g_strdup_printf("pty:%s", pty_name);
> +    chr->filename = g_strdup_printf("pty:%s", s->pty_name);
>      qemu_printf("char device redirected to %s (label %s)\n",
> -                pty_name, chr->label);
> +                s->pty_name, chr->label);
>
> -    s = PTY_CHARDEV(chr);
>      s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd));
>      name = g_strdup_printf("chardev-pty-%s", chr->label);
>      qio_channel_set_name(s->ioc, name);
> @@ -364,7 +363,7 @@ static bool pty_chr_open(Chardev *chr, ChardevBackend
> *backend, Error **errp)
>
>      /* create symbolic link */
>      if (path) {
> -        int res = symlink(pty_name, path);
> +        int res = symlink(s->pty_name, path);
>
>          if (res != 0) {
>              error_setg_errno(errp, errno, "Failed to create PTY symlink");
> --
> 2.48.1
>
>

[-- Attachment #2: Type: text/html, Size: 4061 bytes --]

  reply	other threads:[~2025-12-05 15:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-04 15:42 [PATCH v2 00/10] chardev: cleanup Vladimir Sementsov-Ogievskiy
2025-12-04 15:42 ` [PATCH v2 01/10] ui/spice: Require spice-server >= 0.15.0 Vladimir Sementsov-Ogievskiy
2025-12-05 15:09   ` Marc-André Lureau
2025-12-04 15:42 ` [PATCH v2 02/10] ui/spice: drop SPICE_HAS_ATTACHED_WORKER macro Vladimir Sementsov-Ogievskiy
2025-12-05 15:09   ` Marc-André Lureau
2025-12-04 15:42 ` [PATCH v2 03/10] chardev: ChardevClass: consistent naming for handlers Vladimir Sementsov-Ogievskiy
2025-12-05 15:11   ` Marc-André Lureau
2025-12-04 15:42 ` [PATCH v2 04/10] chardev: consistent naming for ChardevClass handlers implementations Vladimir Sementsov-Ogievskiy
2025-12-04 15:42 ` [PATCH v2 05/10] chardev: .chr_open(): drop be_opened parameter Vladimir Sementsov-Ogievskiy
2025-12-05 15:14   ` Marc-André Lureau
2025-12-04 15:42 ` [PATCH v2 06/10] chardev: .chr_open(): add boolean return value Vladimir Sementsov-Ogievskiy
2025-12-05 15:15   ` Marc-André Lureau
2025-12-05 15:18   ` Marc-André Lureau
2025-12-04 15:42 ` [PATCH v2 07/10] chardev/char-pty: store pty_name into PtyChardev state Vladimir Sementsov-Ogievskiy
2025-12-05 15:20   ` Marc-André Lureau [this message]
2025-12-04 15:42 ` [PATCH v2 08/10] chardev: introduce .chr_get_pty_name() handler Vladimir Sementsov-Ogievskiy
2025-12-05 15:24   ` Marc-André Lureau
2025-12-04 15:42 ` [PATCH v2 09/10] chardev: rework filename handling Vladimir Sementsov-Ogievskiy
2025-12-05 15:33   ` Marc-André Lureau
2025-12-05 21:03     ` Vladimir Sementsov-Ogievskiy
2025-12-04 15:42 ` [PATCH v2 10/10] chardev/char: qemu_char_open(): add return value Vladimir Sementsov-Ogievskiy
2025-12-05 15:34   ` Marc-André Lureau
2025-12-04 17:14 ` [PATCH v2 00/10] chardev: cleanup Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMxuvayOyP19mPEASBqkuiLw=CiWqWE4hocM6v9tj5pOxZtFJA@mail.gmail.com' \
    --to=marcandre.lureau@redhat.com \
    --cc=d-tatianin@yandex-team.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).