Re: [PATCH] Fix getlogin() to check only stdin to get a valid tty

Stefan Tauner <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Thu, 13 Jul 2023 18:57:32 +0200
Jordi Sanfeliu via Newlib <[email protected]> wrote:

> -  if (((tty = ttyname (0)) == 0)
> -      || ((tty = ttyname (1)) == 0)
> -      || ((tty = ttyname (2)) == 0))
> -    return 0;
> +  if ((tty = ttyname (0)) == 0)
> +      if ((tty = ttyname (1)) == 0)
> +          if ((tty = ttyname (2)) == 0)
> +              return 0;

IMHO the bug arose simply because of a || vs. && confusion. You can
just replace the || with && and have exactly the same effect as this
patch but it would be more customary.
-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.