This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 4/5] linux ttyname and ttyname_r: Make the TTY equivalence tests consistent [BZ #22145]


On Thu, 12 Oct 2017 07:16:15 -0400,
Christian Brauner wrote:
> On Wed, Oct 11, 2017 at 11:53:20PM -0400, Luke Shumaker wrote:
> > +static inline int
> > +is_mytty(struct stat64 *mytty, struct stat64 *maybe)
> > +{
> > +  return 1
> > +#ifdef _STATBUF_ST_RDEV
> > +    && S_ISCHR (maybe->st_mode)
> > +    && maybe->st_rdev == mytty->st_rdev
> > +#endif
> > +    && maybe->st_ino == mytty->st_ino
> > +    && maybe->st_dev == mytty->st_dev;
> > +}
> 
> I find that hard to read. At first I thought this would unconditionally return
> 1. I'd rather prefer something like (In the appropriate GNU coding style
> eventually of course.):
> 
> static inline bool is_mytty(struct stat64 *mytty, struct stat64 *maybe)
> {
> 	if (maybe->st_ino == mytty->st_ino && maybe->st_dev == mytty->st_dev
> #ifdef _STATBUF_ST_RDEV
> 	    && S_ISCHR(maybe->st_mode) && maybe->st_rdev == mytty->st_rdev
> #endif
> 	    )
> 		return true;
> 
> 	return false;
> }
> 
> But others might be fine with it.

I'm fine either way.  If the consensus is reformat it, I'll reformat
it.

>                                   But I think having it return a bool here is
> perfectly fine since there's no other possible outcome than true or false.

So why doesn't is_pty return a bool?  I was mimicing the style already
in the file.

-- 
Happy hacking,
~ Luke Shumaker


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]