From owner-freebsd-hackers Sat Jan 11 04:25:04 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id EAA15835 for hackers-outgoing; Sat, 11 Jan 1997 04:25:04 -0800 (PST) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id EAA15772 for ; Sat, 11 Jan 1997 04:24:56 -0800 (PST) Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id NAA21924 for hackers@freebsd.org; Sat, 11 Jan 1997 13:24:46 +0100 Received: (from j@localhost) by uriah.heep.sax.de (8.8.4/8.6.9) id NAA29742; Sat, 11 Jan 1997 13:14:24 +0100 (MET) Message-ID: 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 References: <199701110142.CAA28453@xp11.frmug.org> <199701110834.TAA07745@genesis.atrad.adelaide.edu.au> X-Mailer: Mutt 0.55-PL10 Mime-Version: 1.0 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <199701110834.TAA07745@genesis.atrad.adelaide.edu.au>; from Michael Smith on Jan 11, 1997 19:04:36 +1030 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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. ;-)