#1587 <https://bugs.freedesktop.org/attachment.cgi?id=1587> Call to
    uname should not check for return == 0, but for >= 0 instead
This commit is contained in:
Alan Coopersmith 2004-12-22 08:28:16 +00:00
parent fa0677ab43
commit 3035739e5b
2 changed files with 9 additions and 3 deletions

View File

@ -1765,7 +1765,11 @@ xf86PrintBanner()
{ {
struct utsname name; struct utsname name;
if (uname(&name) == 0) { /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
and Irix) and Single Unix Spec 3 just say that non-negative is success.
All agree that failure is represented by a negative number.
*/
if (uname(&name) >= 0) {
ErrorF("Current Operating System: %s %s %s %s %s\n", ErrorF("Current Operating System: %s %s %s %s %s\n",
name.sysname, name.nodename, name.release, name.version, name.machine); name.sysname, name.nodename, name.release, name.version, name.machine);
} }

View File

@ -20,7 +20,7 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c,v 1.3 2003/06/10 20:48:01 tsi Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c,v 1.2tsi Exp $ */
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
@ -166,10 +166,12 @@ promIsP1275(void)
#elif defined(sun) #elif defined(sun)
struct utsname buffer; struct utsname buffer;
if ((uname(&buffer) == 0) && !strcmp(buffer.machine, "sun4u")) if ((uname(&buffer) >= 0) && !strcmp(buffer.machine, "sun4u"))
promP1275 = TRUE; promP1275 = TRUE;
else else
promP1275 = FALSE; promP1275 = FALSE;
#elif defined(__FreeBSD__)
promP1275 = TRUE;
#else #else
#error Missing promIsP1275() function for this OS #error Missing promIsP1275() function for this OS
#endif #endif