Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: missing braces or wrong indent?



On Sat, 2019-05-11 at 20:04 +0200, Mikael Magnusson wrote:
> Just submitted a new coverity build and looked at some stuff it was
> unhappy about; this isn't one of them but what is going on here?
> 
> clone.c::bin_clone
> 55
>     if (!pid) {
> 	clearjobtab(0);
> 	ppid = getppid();
> 	mypid = getpid();
> #ifdef HAVE_SETSID
> 	if (setsid() != mypid)
> 	    zwarnnam(nam, "failed to create new session: %e", errno);
> #elif defined(TIOCNOTTY)
> 	    if (ioctl(SHTTY, TIOCNOTTY, 0))
> 	    zwarnnam(*args, "%e", errno);
> 	    setpgrp(0L, mypid);
> #endif
> 	dup2(ttyfd,0);
>
> This/these if statements look completely bogusly indented, but maybe
> it's also missing braces? I can't tell because I have no idea what it
> wants to accomplish.

I'd guess just the indentation; I can't see why the setpgrp() would be
particularly useful on failure.  Alternatively, possibly there could
even be an "else" before the setpgrp()?  Presumably this is rarely
compiled and even then the ioctl() doesn't usually fail so very hard to
see the effect of.

pws





Messages sorted by: Reverse Date, Date, Thread, Author