Skip to content

Commit f59b93c

Browse files
committed
[libc] clang-format
1 parent c645ddf commit f59b93c

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

libc/src/sys/time/linux/utimes.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "src/sys/time/utimes.h"
1010

11-
#include "hdr/types/struct_timeval.h"
1211
#include "hdr/fcntl_macros.h"
12+
#include "hdr/types/struct_timeval.h"
1313

1414
#include "src/__support/OSUtil/syscall.h"
1515
#include "src/__support/common.h"
@@ -22,11 +22,11 @@ namespace LIBC_NAMESPACE_DECL {
2222

2323
LLVM_LIBC_FUNCTION(int, utimes, (const char *path, const struct timeval times[2])) {
2424
int ret;
25-
26-
#ifdef SYS_utimes
25+
26+
#ifdef SYS_utimes
2727
// No need to define a timespec struct, use the syscall directly.
2828
ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_utimes, path, times);
29-
#elif defined(SYS_utimensat)
29+
#elif defined(SYS_utimensat)
3030
//the utimensat syscall requires a timespec struct, not timeval.
3131
struct timespec ts[2];
3232
struct timespec *ts_ptr = nullptr; // default value if times is NULL
@@ -60,10 +60,10 @@ namespace LIBC_NAMESPACE_DECL {
6060
// flags=0 means don't follow symlinks (like utimes)
6161
ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_utimensat, AT_FDCWD, path,
6262
ts_ptr, 0);
63-
64-
#else
65-
#error "utimensat and utimes syscalls not available."
66-
#endif // SYS_utimensat
63+
64+
#else
65+
#error "utimensat and utimes syscalls not available."
66+
#endif // SYS_utimensat
6767

6868
if (ret < 0) {
6969
libc_errno = -ret;
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
1-
//===-- Unittests for utimes -----------------------------------------------===//
1+
//===-- Unittests for utimes
2+
//-----------------------------------------------===//
23
//
34
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45
// See https://llvm.org/LICENSE.txt for license information.
56
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67
//
78
//===-----------------------------------------------------------------------===//
89

9-
#include "src/fcntl/open.h"
10-
#include "src/unistd/close.h"
10+
#include "hdr/fcntl_macros.h"
11+
#include "hdr/types/struct_timeval.h"
12+
#include "src/errno/libc_errno.h"
13+
#include "src/fcntl/open.h"
1114
#include "src/stdio/remove.h"
12-
#include "src/sys/stat/stat.h"
13-
#include "src/unistd/unlink.h"
14-
#include "test/UnitTest/Test.h"
15-
#include "src/errno/libc_errno.h"
15+
#include "src/sys/stat/stat.h"
16+
#include "src/sys/time/utimes.h"
17+
#include "src/unistd/close.h"
18+
#include "src/unistd/unlink.h"
1619
#include "test/UnitTest/ErrnoSetterMatcher.h"
17-
#include "hdr/types/struct_timeval.h"
18-
#include "hdr/fcntl_macros.h"
19-
#include "src/sys/time/utimes.h"
20+
#include "test/UnitTest/Test.h"
2021
#include <fcntl.h>
21-
constexpr const char* FILE_PATH = "utimes.test";
22+
constexpr const char *FILE_PATH = "utimes.test";
2223

2324
// SUCCESS: Takes a file and successfully updates
2425
// its last access and modified times.
2526
TEST(LlvmLibcUtimesTest, ChangeTimesSpecific){
2627
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
27-
28+
2829
// const char* FILE_PATH = "testdata/__utimes_changetimes.test";
29-
30+
3031
auto TEST_FILE = libc_make_test_file_path(FILE_PATH);
3132
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT);
3233
ASSERT_GT(fd, 0);
3334
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
34-
35+
3536
// make a dummy timeval struct
3637
struct timeval times[2];
3738
times[0].tv_sec = 54321;
@@ -45,31 +46,31 @@ TEST(LlvmLibcUtimesTest, ChangeTimesSpecific){
4546
// verify the times values against stat of the TEST_FILE
4647
struct stat statbuf;
4748
ASSERT_EQ(LIBC_NAMESPACE::stat(FILE_PATH, &statbuf), 0);
48-
49+
4950
// seconds
5051
ASSERT_EQ(statbuf.st_atim.tv_sec, times[0].tv_sec);
5152
ASSERT_EQ(statbuf.st_mtim.tv_sec, times[1].tv_sec);
5253

5354
//microseconds
5455
ASSERT_EQ(statbuf.st_atim.tv_nsec, times[0].tv_usec * 1000);
5556
ASSERT_EQ(statbuf.st_mtim.tv_nsec, times[1].tv_usec * 1000);
56-
57-
ASSERT_THAT(LIBC_NAMESPACE::remove(TEST_FILE), Succeeds(0));
57+
58+
ASSERT_THAT(LIBC_NAMESPACE::remove(TEST_FILE), Succeeds(0));
5859
}
5960

6061
// FAILURE: Invalid values in the timeval struct
6162
// to check that utimes rejects it.
6263
TEST(LlvmLibcUtimesTest, InvalidMicroseconds){
63-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
64-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
64+
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
65+
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
6566

6667
// const char* FILE_PATH = "testdata/__utimes_invalidmicroseconds.test";
67-
68+
6869
auto TEST_FILE = libc_make_test_file_path(FILE_PATH);
6970
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT);
7071
ASSERT_GT(fd, 0);
7172
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
72-
73+
7374
// make a dummy timeval struct
7475
// populated with bad usec values
7576
struct timeval times[2];
@@ -80,7 +81,7 @@ TEST(LlvmLibcUtimesTest, InvalidMicroseconds){
8081

8182
// ensure utimes fails
8283
ASSERT_THAT(LIBC_NAMESPACE::utimes(FILE_PATH, times), Fails(EINVAL));
83-
84+
8485
// check for failure on
8586
// the other possible bad values
8687

@@ -90,6 +91,6 @@ TEST(LlvmLibcUtimesTest, InvalidMicroseconds){
9091
times[1].tv_usec = 1000;
9192

9293
// ensure utimes fails once more
93-
ASSERT_THAT(LIBC_NAMESPACE::utimes(FILE_PATH, times), Fails(EINVAL));
94-
ASSERT_THAT(LIBC_NAMESPACE::remove(TEST_FILE), Succeeds(0));
94+
ASSERT_THAT(LIBC_NAMESPACE::utimes(FILE_PATH, times), Fails(EINVAL));
95+
ASSERT_THAT(LIBC_NAMESPACE::remove(TEST_FILE), Succeeds(0));
9596
}

0 commit comments

Comments
 (0)