Date: Sat, 11 Jan 1997 13:14:24 +0100 From: j@uriah.heep.sax.de (J Wunsch) To: hackers@freebsd.org Subject: Re: unused variable in su Message-ID: <Mutt.19970111131424.j@uriah.heep.sax.de> In-Reply-To: <199701110834.TAA07745@genesis.atrad.adelaide.edu.au>; from Michael Smith on Jan 11, 1997 19:04:36 %2B1030 References: <199701110142.CAA28453@xp11.frmug.org> <199701110834.TAA07745@genesis.atrad.adelaide.edu.au>
next in thread | previous in thread | raw e-mail | index | archive | help
As Michael Smith wrote: > > line 101: char shellbuf[MAXPATHLEN]; > > line 171: shell = strcpy(shellbuf, pwd->pw_shell); > > > > Shellbuf is not referenced elsewhere, is there any reason not to > > remove shellbuf (and adjust line 171), or is there a side effect I don't > > see? > > pwd is recycled later, and shell is potentially reset later, so > this is the 'correct' way to do it. Don't change it. Still, it's fairly obfuscated code. It could be better worded: if (asme) if (pwd->pw_shell && *pwd->pw_shell) { (void)strcpy(shellbuf, pwd->pw_shell); shell = shellbuf; } else { shell = _PATH_BSHELL; iscsh = NO; } This would be less confusing for compilers and human readers. Btw., shouldn't it better be a strncpy() anyway? Sure, /etc/shells is at the mercy of the sysadmin, but he isn't unfailable. -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Mutt.19970111131424.j>