Skip to content

Commit 89494d2

Browse files
committed
style: fix clang-format issues
Signed-off-by: ZakyHermawan <[email protected]>
1 parent c44b475 commit 89494d2

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

libc/src/unistd/linux/gethostname.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#include "src/__support/common.h"
1414
#include "src/__support/macros/config.h"
1515

16+
#include "src/errno/libc_errno.h"
1617
#include "src/string/strlen.h"
1718
#include "src/string/strncpy.h"
18-
#include "src/errno/libc_errno.h"
1919

2020
#include <sys/syscall.h> // For syscall numbers.
2121
#include <sys/utsname.h>
@@ -25,7 +25,6 @@ namespace LIBC_NAMESPACE_DECL {
2525
// Matching the behavior of glibc version 2.2 and later.
2626
// Copies up to len bytes from the returned nodename field into name.
2727
LLVM_LIBC_FUNCTION(int, gethostname, (char *name, size_t len)) {
28-
2928
// Check for invalid pointer
3029
if (name == nullptr) {
3130
libc_errno = EFAULT;
@@ -35,18 +34,19 @@ LLVM_LIBC_FUNCTION(int, gethostname, (char *name, size_t len)) {
3534
struct utsname unameData;
3635
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_uname, &unameData);
3736

38-
// Checks if the length of the nodename was greater than or equal to len, and if it is,
39-
// then the function returns -1 with errno set to ENAMETOOLONG.
40-
// In this case, a terminating null byte is not included in the returned name.
41-
if (strlen(unameData.nodename) >= len)
42-
{
37+
// Checks if the length of the nodename was greater than or equal to len, and
38+
// if it is, then the function returns -1 with errno set to ENAMETOOLONG. In
39+
// this case, a terminating null byte is not included in the returned name.
40+
if (strlen(unameData.nodename) >= len) {
4341
strncpy(name, unameData.nodename, len);
4442
libc_errno = ENAMETOOLONG;
4543
return -1;
4644
}
4745

48-
// If the size of the array name is not large enough (less than the size of nodename with null termination), then anything might happen.
49-
// In this case, what happens to the array name will be determined by the implementation of LIBC_NAMESPACE_DECL::strncpy
46+
// If the size of the array name is not large enough (less than the size of
47+
// nodename with null termination), then anything might happen. In this case,
48+
// what happens to the array name will be determined by the implementation of
49+
// LIBC_NAMESPACE_DECL::strncpy
5050
strncpy(name, unameData.nodename, len);
5151

5252
if (ret < 0) {
@@ -58,5 +58,3 @@ LLVM_LIBC_FUNCTION(int, gethostname, (char *name, size_t len)) {
5858
}
5959

6060
} // namespace LIBC_NAMESPACE_DECL
61-
62-

libc/test/src/unistd/gethostname_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ TEST(LlvmLibcGetHostNameTest, GetCurrHostName) {
2121
ASSERT_ERRNO_EQ(ENAMETOOLONG);
2222

2323
// test for invalid pointer
24-
char* nptr = nullptr;
24+
char *nptr = nullptr;
2525
ret = LIBC_NAMESPACE::gethostname(nptr, 1);
2626
ASSERT_EQ(ret, -1);
2727
ASSERT_ERRNO_EQ(EFAULT);

0 commit comments

Comments
 (0)