diff --git a/src/getcomputername.cpp b/src/getcomputername.cpp index e363cf167..3e480b9ad 100644 --- a/src/getcomputername.cpp +++ b/src/getcomputername.cpp @@ -12,7 +12,7 @@ //! //! @exception errno Passes these errors via errno to GetLastError: //! - ERROR_INVALID_FUNCTION: getlogin_r() returned an unrecognized error code -//! - ERROR_INVALID_ADDRESS: buffer is an invalid address +//! - ERROR_INVALID_ADDRESS: buffer is an invalid address //! - ERROR_GEN_FAILURE: buffer not large enough //! //! @retval username as UTF-8 string, or null if unsuccessful @@ -42,6 +42,4 @@ char* GetComputerName() } return strdup(computername.c_str()); - } - diff --git a/src/getcomputername.h b/src/getcomputername.h index 66b0c352b..363210921 100644 --- a/src/getcomputername.h +++ b/src/getcomputername.h @@ -4,6 +4,6 @@ PAL_BEGIN_EXTERNC -char* GetComputerName(); +char *GetComputerName(); PAL_END_EXTERNC diff --git a/src/getfullyqualifiedname.cpp b/src/getfullyqualifiedname.cpp index 5d711c2f3..44178a0a5 100644 --- a/src/getfullyqualifiedname.cpp +++ b/src/getfullyqualifiedname.cpp @@ -12,7 +12,6 @@ //! @brief GetFullyQualifiedName retrieves the fully qualifed dns name of the host //! //! @exception errno Passes these errors via errno to GetLastError: -//! - ERROR_BAD_ENVIRONMENT: locale is not UTF-8 (from GetComputerName) //! - ERROR_INVALID_FUNCTION: getlogin_r() returned an unrecognized error code (from GetComputerName) //! - ERROR_INVALID_ADDRESS: buffer is an invalid address (from GetComputerName) //! - ERROR_GEN_FAILURE: buffer not large enough (from GetComputerName) @@ -21,12 +20,12 @@ //! @retval username as UTF-8 string, or null if unsuccessful //! -char* GetFullyQualifiedName() +char *GetFullyQualifiedName() { errno = 0; - + char *computerName = GetComputerName(); - if (NULL == computerName) + if (computerName == NULL) { return NULL; } @@ -37,7 +36,6 @@ char* GetFullyQualifiedName() } struct addrinfo hints, *info; - int gai_result; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; /*either IPV4 or IPV6*/ @@ -45,12 +43,12 @@ char* GetFullyQualifiedName() hints.ai_flags = AI_CANONNAME; /* There are several ways to get the domain name: - * uname(2), gethostbyname(3), resolver(3), getdomainname(2), - * and getaddrinfo(3). Some of these are not portable, some aren't - * POSIX compliant, and some are being deprecated. Getaddrinfo seems - * to be the best choice right now. + * uname(2), gethostbyname(3), resolver(3), getdomainname(2), + * and getaddrinfo(3). Some of these are not portable, some aren't + * POSIX compliant, and some are being deprecated. getaddrinfo seems + * to be the best choice. */ - if ((gai_result = getaddrinfo(computerName, "http", &hints, &info)) != 0) + if (getaddrinfo(computerName, "http", &hints, &info) != 0) { errno = ERROR_BAD_NET_NAME; return NULL; @@ -58,10 +56,9 @@ char* GetFullyQualifiedName() // info is actually a link-list. We'll just return the first full name - char *fullName = strdup(info->ai_canonname); + char *fullName = strndup(info->ai_canonname, strlen(info->ai_canonname)); freeaddrinfo(info); free(computerName); return fullName; } - diff --git a/src/getfullyqualifiedname.h b/src/getfullyqualifiedname.h index 4db1fd2e7..b44ab68fd 100644 --- a/src/getfullyqualifiedname.h +++ b/src/getfullyqualifiedname.h @@ -4,6 +4,6 @@ PAL_BEGIN_EXTERNC -char* GetFullyQualifiedName(); +char *GetFullyQualifiedName(); PAL_END_EXTERNC diff --git a/src/getlinkcount.cpp b/src/getlinkcount.cpp index 9e8db3d65..1b97a4167 100644 --- a/src/getlinkcount.cpp +++ b/src/getlinkcount.cpp @@ -101,5 +101,4 @@ int32_t GetLinkCount(const char* fileName, int32_t *count) *count = statBuf.st_nlink; return 1; - }