From b0174b3dda95be3858ec54570c1375f2f00e984e Mon Sep 17 00:00:00 2001 From: Frank Kolarek Date: Fri, 14 Jan 2022 14:03:25 -0500 Subject: [PATCH] On Solaris, uname() returns non-negative value As per https://docs.oracle.com/cd/E18752_01/html/816-5167/uname-2.html#REFMAN2uname-2 Solaris version of uname() return a non-negative value on success. Modifying this code to check for a return value of less than zero will work on Solaris as well as Linux and AIX. --- src/logging.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logging.cc b/src/logging.cc index 7a64a78..2458287 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -238,7 +238,7 @@ static ssize_t pwrite(int fd, void* buf, size_t count, off_t offset) { static void GetHostName(string* hostname) { #if defined(HAVE_SYS_UTSNAME_H) struct utsname buf; - if (0 != uname(&buf)) { + if (uname(&buf) < 0) { // ensure null termination on failure *buf.nodename = '\0'; }