Skip to content

Commit

Permalink
On Solaris, uname() returns non-negative value
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fkolarek committed Jan 14, 2022
1 parent 6434410 commit 3dce803
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down

0 comments on commit 3dce803

Please sign in to comment.