Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!emcmanus From: emcmanus@cs.tcd.ie (Eamonn McManus) Newsgroups: comp.unix.sysv386 Subject: Re: Replacement su for SCO Unix Summary: gcc is right, Microsoft is wrong Keywords: SCO, su Message-ID: <1740@tws8.cs.tcd.ie> Date: 2 Oct 90 21:06:12 GMT References: <1990Sep20.163355.7147@robobar.co.uk> <1990Sep21.143435.9810@dce.ie> <143@guug.guug.de> Reply-To: em@dce.ie (Eamonn McManus) Organization: Computer Science Department, Trinity College Dublin Lines: 17 ott@guug.guug.de (Joachim Ott Munich-Germany) writes: >> const char *user = "root", *shell = NULL; > ... >> su(pwd, login, shell ? shell : pwd->pw_shell, argv + i - 1); >... >'shell ?' means >'shell != 0' and *not* 'shell != NULL'. You should not rely on >NULL being the same as 0. Try the line with '(shell != NULL) ?', >the warning should be gone. The code as it stands is correct. The reason the Microsoft compiler complains is not because of the implicit comparison against 0 but because one of the ?: branches has type `const char *' and the other type `char *'. It should instead promote `const char *' to `char *'. -- Eamonn McManus Fingers are for fuguing.