1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 04:17:34 +00:00

Everywhere: Run clang-format

This commit is contained in:
Idan Horowitz 2022-04-01 20:58:27 +03:00 committed by Linus Groh
parent 0376c127f6
commit 086969277e
1665 changed files with 8479 additions and 8479 deletions

View file

@ -348,9 +348,9 @@ TEST_CASE(writev)
EXPECT(rc == 0);
iovec iov[2];
iov[0].iov_base = const_cast<void*>((const void*)"Hello");
iov[0].iov_base = const_cast<void*>((void const*)"Hello");
iov[0].iov_len = 5;
iov[1].iov_base = const_cast<void*>((const void*)"Friends");
iov[1].iov_base = const_cast<void*>((void const*)"Friends");
iov[1].iov_len = 7;
int nwritten = writev(pipefds[1], iov, 2);
EXPECT_EQ(nwritten, 12);

View file

@ -33,7 +33,7 @@ TEST_CASE(test_mktemp_unique_filename)
} else {
wait(NULL);
auto path1 = String::formatted("{}", reinterpret_cast<const char*>(ptr));
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mktemp.XXXXXX";
auto path2 = String::formatted("{}", mktemp(path));
@ -63,7 +63,7 @@ TEST_CASE(test_mkdtemp_unique_filename)
} else {
wait(NULL);
auto path1 = String::formatted("{}", reinterpret_cast<const char*>(ptr));
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mkdtemp.XXXXXX";
auto path2 = String::formatted("{}", mkdtemp(path));
@ -101,7 +101,7 @@ TEST_CASE(test_mkstemp_unique_filename)
} else {
wait(NULL);
auto path1 = String::formatted("{}", reinterpret_cast<const char*>(ptr));
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mkstemp.XXXXXX";
auto fd = mkstemp(path);

View file

@ -12,7 +12,7 @@
TEST_CASE(setjmp)
{
jmp_buf env;
volatile int set = 1;
int volatile set = 1;
if (setjmp(env)) {
EXPECT_EQ(set, 0);
@ -29,7 +29,7 @@ TEST_CASE(setjmp)
TEST_CASE(setjmp_zero)
{
jmp_buf env;
volatile int set = 1;
int volatile set = 1;
switch (setjmp(env)) {
case 0:
@ -50,7 +50,7 @@ TEST_CASE(setjmp_zero)
TEST_CASE(setjmp_value)
{
jmp_buf env;
volatile int set = 1;
int volatile set = 1;
switch (setjmp(env)) {
case 0:
@ -71,7 +71,7 @@ TEST_CASE(setjmp_value)
TEST_CASE(sigsetjmp)
{
sigjmp_buf env;
volatile int set = 1;
int volatile set = 1;
if (sigsetjmp(env, 0)) {
EXPECT_EQ(set, 0);
@ -88,7 +88,7 @@ TEST_CASE(sigsetjmp)
TEST_CASE(sigsetjmp_zero)
{
sigjmp_buf env;
volatile int set = 1;
int volatile set = 1;
switch (sigsetjmp(env, 0)) {
case 0:
@ -109,7 +109,7 @@ TEST_CASE(sigsetjmp_zero)
TEST_CASE(sigsetjmp_value)
{
sigjmp_buf env;
volatile int set = 1;
int volatile set = 1;
switch (sigsetjmp(env, 0)) {
case 0:

View file

@ -8,7 +8,7 @@
#include <LibTest/TestCase.h>
#include <time.h>
const auto expected_epoch = "Thu Jan 1 00:00:00 1970\n"sv;
auto const expected_epoch = "Thu Jan 1 00:00:00 1970\n"sv;
class TimeZoneGuard {
public:

View file

@ -10,19 +10,19 @@
#include <string.h>
struct TestCase {
const u8* haystack;
u8 const* haystack;
size_t haystack_length;
const u8* needle;
u8 const* needle;
size_t needle_length;
ssize_t matching_offset { -1 };
};
const static TestCase g_test_cases[] = {
{ (const u8*) {}, 0u, (const u8*) {}, 0u, 0 },
{ (u8 const*) {}, 0u, (u8 const*) {}, 0u, 0 },
{ (const u8[]) { 1, 2, 3 }, 3u, (const u8[]) { 1, 2, 3 }, 3u, 0 },
{ (const u8[]) { 1, 2, 4 }, 3u, (const u8[]) { 1, 2, 3 }, 3u, -1 },
{ (const u8*)"abcdef", 6u, (const u8[]) {}, 0u, 0 },
{ (const u8*)"abcdef", 6u, (const u8*)"de", 2u, 3 },
{ (u8 const*)"abcdef", 6u, (const u8[]) {}, 0u, 0 },
{ (u8 const*)"abcdef", 6u, (u8 const*)"de", 2u, 3 },
{ (const u8[]) { 0, 1, 2, 5, 2, 5 }, 6u, (const u8[]) { 1 }, 1u, 1 },
{ (const u8[]) { 0, 1, 2, 5, 2, 5 }, 6u, (const u8[]) { 1, 2 }, 2u, 1 },
{ (const u8[]) { 0, 1, 1, 2 }, 4u, (const u8[]) { 1, 5 }, 2u, -1 },
@ -33,7 +33,7 @@ const static TestCase g_test_cases[] = {
TEST_CASE(memmem_search)
{
size_t i = 0;
for (const auto& test_case : g_test_cases) {
for (auto const& test_case : g_test_cases) {
auto expected = test_case.matching_offset >= 0 ? test_case.haystack + test_case.matching_offset : nullptr;
auto result = memmem(test_case.haystack, test_case.haystack_length, test_case.needle, test_case.needle_length);
if (result != expected) {

View file

@ -19,10 +19,10 @@ struct SortableObject {
int m_payload;
};
static int compare_sortable_object(const void* a, const void* b)
static int compare_sortable_object(void const* a, void const* b)
{
const int key1 = static_cast<const SortableObject*>(a)->m_key;
const int key2 = static_cast<const SortableObject*>(b)->m_key;
int const key1 = static_cast<SortableObject const*>(a)->m_key;
int const key2 = static_cast<SortableObject const*>(b)->m_key;
if (key1 < key2) {
return -1;
} else if (key1 == key2) {
@ -60,16 +60,16 @@ TEST_CASE(quick_sort)
qsort(test_objects.data(), test_objects.size(), sizeof(SortableObject), compare_sortable_object);
// Check that the objects are sorted by key
for (auto i = 0u; i + 1 < test_objects.size(); ++i) {
const auto& key1 = test_objects[i].m_key;
const auto& key2 = test_objects[i + 1].m_key;
auto const& key1 = test_objects[i].m_key;
auto const& key2 = test_objects[i + 1].m_key;
if (key1 > key2) {
FAIL(String::formatted("saw key {} before key {}\n", key1, key2));
}
}
// Check that the object's payloads have not been corrupted
for (auto i = 0u; i < test_objects.size(); ++i) {
const auto expected = calc_payload_for_pos(i);
const auto payload = test_objects[i].m_payload;
auto const expected = calc_payload_for_pos(i);
auto const payload = test_objects[i].m_payload;
if (payload != expected) {
FAIL(String::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
}

View file

@ -21,7 +21,7 @@ static constexpr char PATH_LOREM_250[] = "This-is-an-annoyingly-long-name-that-s
static constexpr size_t ITERATION_DEPTH = 17;
static void check_result(const char* what, const String& expected, const char* actual)
static void check_result(char const* what, String const& expected, char const* actual)
{
if (expected != actual)
FAIL(String::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));

View file

@ -65,7 +65,7 @@ constexpr static Array<unsigned char, 32> to_value_t(T x)
}
template<size_t N>
constexpr static Array<unsigned char, 32> str_to_value_t(const char (&x)[N])
constexpr static Array<unsigned char, 32> str_to_value_t(char const (&x)[N])
{
Array<unsigned char, 32> value { 0 };
for (size_t i = 0; i < N; ++i)
@ -78,7 +78,7 @@ struct Argument {
void* data;
};
static Array<u8, 32> arg_to_value_t(const Argument& arg)
static Array<u8, 32> arg_to_value_t(Argument const& arg)
{
if (arg.size == 1)
return to_value_t(*(u8*)arg.data);
@ -140,8 +140,8 @@ Argument charstararg1 { sizeof(charstar), &_charstararg1[0] };
Argument charstararg2 { sizeof(charstar), &_charstararg2[0] };
struct TestSuite {
const char* format;
const char* input;
char const* format;
char const* input;
int expected_return_value;
size_t argument_count;
Argument arguments[8];
@ -184,7 +184,7 @@ const TestSuite test_suites[] {
bool g_any_failed = false;
static bool check_value_conformance(const TestSuite& test)
static bool check_value_conformance(TestSuite const& test)
{
bool fail = false;
for (size_t i = 0; i < test.argument_count; ++i) {
@ -192,8 +192,8 @@ static bool check_value_conformance(const TestSuite& test)
auto arg_value = arg_to_value_t(arg);
auto& value = test.expected_values[i];
if (arg_value != value) {
auto arg_ptr = (const u32*)arg_value.data();
auto value_ptr = (const u32*)value.data();
auto arg_ptr = (u32 const*)arg_value.data();
auto value_ptr = (u32 const*)value.data();
printf(" value %zu FAIL,\n", i);
printf(" expected %08x%08x%08x%08x%08x%08x%08x%08x\n",
value_ptr[0], value_ptr[1], value_ptr[2], value_ptr[3],
@ -210,7 +210,7 @@ static bool check_value_conformance(const TestSuite& test)
return !fail;
}
static void do_one_test(const TestSuite& test)
static void do_one_test(TestSuite const& test)
{
printf("Testing '%s' against '%s'...\n", test.input, test.format);

View file

@ -13,11 +13,11 @@
#define NODE(node) static_cast<struct search_tree_node*>(node)
#define ROOTP(root) reinterpret_cast<void**>(root)
#define COMP(func) reinterpret_cast<int (*)(const void*, const void*)>(func)
#define COMP(func) reinterpret_cast<int (*)(void const*, void const*)>(func)
#define U8(value) static_cast<u8>(value)
struct twalk_test_entry {
const void* node;
void const* node;
VISIT order;
int depth;
};
@ -30,7 +30,7 @@ TEST_CASE(tsearch)
{
struct search_tree_node* root = nullptr;
void* ret;
const char* key;
char const* key;
char* search;
// Try a nullptr rootp.
@ -150,8 +150,8 @@ TEST_CASE(tfind)
delete_node_recursive(root);
}
void twalk_action(const void* node, VISIT order, int depth);
void twalk_action(const void* node, VISIT order, int depth)
void twalk_action(void const* node, VISIT order, int depth);
void twalk_action(void const* node, VISIT order, int depth)
{
static int count = 0;
static const struct twalk_test_entry* tests = nullptr;

View file

@ -18,16 +18,16 @@
template<typename TArg>
struct Testcase {
const char* dest;
char const* dest;
size_t dest_n;
const char* fmt;
char const* fmt;
const TArg arg;
int expected_return;
const char* dest_expected;
char const* dest_expected;
size_t dest_expected_n; // == dest_n
};
static String show(const ByteBuffer& buf)
static String show(ByteBuffer const& buf)
{
StringBuilder builder;
for (size_t i = 0; i < buf.size(); ++i) {
@ -46,7 +46,7 @@ static String show(const ByteBuffer& buf)
}
template<typename TArg>
static bool test_single(const Testcase<TArg>& testcase)
static bool test_single(Testcase<TArg> const& testcase)
{
constexpr size_t SANDBOX_CANARY_SIZE = 8;
@ -109,41 +109,41 @@ static bool test_single(const Testcase<TArg>& testcase)
// Drop the NUL terminator added by the C++ compiler.
#define LITERAL(x) x, (sizeof(x) - 1)
static const char* const POISON = (const char*)1;
static char const* const POISON = (char const*)1;
TEST_CASE(golden_path)
{
EXPECT(test_single<const char*>({ LITERAL("Hello World!\0\0\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend!\0\0") }));
EXPECT(test_single<const char*>({ LITERAL("Hello World!\0\0\0"), "Hello %s!", "Friend", 13, LITERAL("Hello Friend!\0\0") }));
EXPECT(test_single<const char*>({ LITERAL("aaaaaaaaaa"), "whf", POISON, 3, LITERAL("whf\0aaaaaa") }));
EXPECT(test_single<const char*>({ LITERAL("aaaaaaaaaa"), "w%sf", "h", 3, LITERAL("whf\0aaaaaa") }));
EXPECT(test_single<char const*>({ LITERAL("Hello World!\0\0\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend!\0\0") }));
EXPECT(test_single<char const*>({ LITERAL("Hello World!\0\0\0"), "Hello %s!", "Friend", 13, LITERAL("Hello Friend!\0\0") }));
EXPECT(test_single<char const*>({ LITERAL("aaaaaaaaaa"), "whf", POISON, 3, LITERAL("whf\0aaaaaa") }));
EXPECT(test_single<char const*>({ LITERAL("aaaaaaaaaa"), "w%sf", "h", 3, LITERAL("whf\0aaaaaa") }));
}
TEST_CASE(border_cases)
{
EXPECT(test_single<const char*>({ LITERAL("Hello World!\0\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend!\0") }));
EXPECT(test_single<const char*>({ LITERAL("AAAA"), "whf", POISON, 3, LITERAL("whf\0") }));
EXPECT(test_single<const char*>({ LITERAL("AAAA"), "%s", "whf", 3, LITERAL("whf\0") }));
EXPECT(test_single<char const*>({ LITERAL("Hello World!\0\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend!\0") }));
EXPECT(test_single<char const*>({ LITERAL("AAAA"), "whf", POISON, 3, LITERAL("whf\0") }));
EXPECT(test_single<char const*>({ LITERAL("AAAA"), "%s", "whf", 3, LITERAL("whf\0") }));
}
TEST_CASE(too_long)
{
EXPECT(test_single<const char*>({ LITERAL("Hello World!\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend\0") }));
EXPECT(test_single<const char*>({ LITERAL("Hello World!\0"), "This source is %s too long!", "just *way*", 35, LITERAL("This source \0") }));
EXPECT(test_single<const char*>({ LITERAL("x"), "This source is %s too long!", "just *way*", 35, LITERAL("\0") }));
EXPECT(test_single<char const*>({ LITERAL("Hello World!\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend\0") }));
EXPECT(test_single<char const*>({ LITERAL("Hello World!\0"), "This source is %s too long!", "just *way*", 35, LITERAL("This source \0") }));
EXPECT(test_single<char const*>({ LITERAL("x"), "This source is %s too long!", "just *way*", 35, LITERAL("\0") }));
}
TEST_CASE(special_cases)
{
EXPECT(test_single<const char*>({ LITERAL(""), "Hello Friend!", POISON, 13, LITERAL("") }));
EXPECT(test_single<char const*>({ LITERAL(""), "Hello Friend!", POISON, 13, LITERAL("") }));
EXPECT_EQ(snprintf(nullptr, 0, "Hello, friend!"), 14);
EXPECT(test_single<const char*>({ LITERAL(""), "", POISON, 0, LITERAL("") }));
EXPECT(test_single<const char*>({ LITERAL("x"), "", POISON, 0, LITERAL("\0") }));
EXPECT(test_single<const char*>({ LITERAL("xx"), "", POISON, 0, LITERAL("\0x") }));
EXPECT(test_single<const char*>({ LITERAL("xxx"), "", POISON, 0, LITERAL("\0xx") }));
EXPECT(test_single<const char*>({ LITERAL(""), "whf", POISON, 3, LITERAL("") }));
EXPECT(test_single<const char*>({ LITERAL("x"), "whf", POISON, 3, LITERAL("\0") }));
EXPECT(test_single<const char*>({ LITERAL("xx"), "whf", POISON, 3, LITERAL("w\0") }));
EXPECT(test_single<char const*>({ LITERAL(""), "", POISON, 0, LITERAL("") }));
EXPECT(test_single<char const*>({ LITERAL("x"), "", POISON, 0, LITERAL("\0") }));
EXPECT(test_single<char const*>({ LITERAL("xx"), "", POISON, 0, LITERAL("\0x") }));
EXPECT(test_single<char const*>({ LITERAL("xxx"), "", POISON, 0, LITERAL("\0xx") }));
EXPECT(test_single<char const*>({ LITERAL(""), "whf", POISON, 3, LITERAL("") }));
EXPECT(test_single<char const*>({ LITERAL("x"), "whf", POISON, 3, LITERAL("\0") }));
EXPECT(test_single<char const*>({ LITERAL("xx"), "whf", POISON, 3, LITERAL("w\0") }));
}
TEST_CASE(octal_values)

View file

@ -14,15 +14,15 @@
#include <string.h>
struct Testcase {
const char* dest;
char const* dest;
size_t dest_n;
const char* src;
char const* src;
size_t src_n;
const char* dest_expected;
char const* dest_expected;
size_t dest_expected_n; // == dest_n
};
static String show(const ByteBuffer& buf)
static String show(ByteBuffer const& buf)
{
StringBuilder builder;
for (size_t i = 0; i < buf.size(); ++i) {
@ -40,7 +40,7 @@ static String show(const ByteBuffer& buf)
return builder.build();
}
static bool test_single(const Testcase& testcase)
static bool test_single(Testcase const& testcase)
{
constexpr size_t SANDBOX_CANARY_SIZE = 8;

View file

@ -18,10 +18,10 @@ static constexpr char TEXT_RESET[] = "\x1b[0m";
static constexpr long long LENIENCY = 8;
struct Testcase {
const char* test_name;
char const* test_name;
int should_consume;
const char* hex;
const char* test_string;
char const* hex;
char const* test_string;
};
static Testcase TESTCASES[] = {
@ -231,7 +231,7 @@ static Testcase TESTCASES[] = {
constexpr size_t NUM_TESTCASES = sizeof(TESTCASES) / sizeof(TESTCASES[0]);
typedef double (*strtod_fn_t)(const char* str, char** endptr);
typedef double (*strtod_fn_t)(char const* str, char** endptr);
static long long cast_ll(double d)
{
@ -250,7 +250,7 @@ static long long cast_ll(double d)
return readable.as_ll;
}
static bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, const char* expect_hex, int expect_consume, long long expect_ll)
static bool is_strtod_close(strtod_fn_t strtod_fn, char const* test_string, char const* expect_hex, int expect_consume, long long expect_ll)
{
union readable_t {
double as_double;
@ -277,7 +277,7 @@ static bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, cons
if (endptr < test_string) {
actual_consume = 999;
} else {
const char* max_endptr = test_string + strlen(test_string);
char const* max_endptr = test_string + strlen(test_string);
actual_consume_possible = endptr <= max_endptr;
actual_consume = endptr - test_string;
}
@ -303,7 +303,7 @@ static bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, cons
return !(wrong_hex || error_cns || wrong_cns);
}
static long long hex_to_ll(const char* hex)
static long long hex_to_ll(char const* hex)
{
long long result = 0;
for (int i = 0; i < 16; ++i) {

View file

@ -13,7 +13,7 @@
TEST_CASE(wcspbrk)
{
const wchar_t* input;
wchar_t const* input;
wchar_t* ret;
// Test empty haystack.
@ -40,7 +40,7 @@ TEST_CASE(wcspbrk)
TEST_CASE(wcsstr)
{
const wchar_t* input = L"abcde";
wchar_t const* input = L"abcde";
wchar_t* ret;
// Empty needle should return haystack.
@ -70,7 +70,7 @@ TEST_CASE(wcsstr)
TEST_CASE(wmemchr)
{
const wchar_t* input = L"abcde";
wchar_t const* input = L"abcde";
wchar_t* ret;
// Empty haystack returns nothing.
@ -102,7 +102,7 @@ TEST_CASE(wmemchr)
TEST_CASE(wmemcpy)
{
const wchar_t* input = L"abc\0def";
wchar_t const* input = L"abc\0def";
auto buf = static_cast<wchar_t*>(malloc(8 * sizeof(wchar_t)));
if (!buf) {
@ -142,7 +142,7 @@ TEST_CASE(wmemset)
TEST_CASE(wmemmove)
{
wchar_t* ret;
const wchar_t* string = L"abc\0def";
wchar_t const* string = L"abc\0def";
auto buf = static_cast<wchar_t*>(calloc(32, sizeof(wchar_t)));
if (!buf) {
@ -324,7 +324,7 @@ TEST_CASE(wcsrtombs)
char buf[MB_LEN_MAX * 4];
const wchar_t good_chars[] = { L'\U0001F41E', L'\U0001F41E', L'\0' };
const wchar_t bad_chars[] = { L'\U0001F41E', static_cast<wchar_t>(0x1111F41E), L'\0' };
const wchar_t* src;
wchar_t const* src;
size_t ret = 0;
// Convert normal and valid wchar_t values.
@ -369,7 +369,7 @@ TEST_CASE(wcsnrtombs)
{
mbstate_t state = {};
const wchar_t good_chars[] = { L'\U0001F41E', L'\U0001F41E', L'\0' };
const wchar_t* src;
wchar_t const* src;
size_t ret = 0;
// Convert nothing.
@ -395,9 +395,9 @@ TEST_CASE(mbsrtowcs)
{
mbstate_t state = {};
wchar_t buf[4];
const char good_chars[] = "\xf0\x9f\x90\x9e\xf0\x9f\x90\x9e";
const char bad_chars[] = "\xf0\x9f\x90\x9e\xf0\xff\x90\x9e";
const char* src;
char const good_chars[] = "\xf0\x9f\x90\x9e\xf0\x9f\x90\x9e";
char const bad_chars[] = "\xf0\x9f\x90\x9e\xf0\xff\x90\x9e";
char const* src;
size_t ret = 0;
// Convert normal and valid multibyte sequences.
@ -445,8 +445,8 @@ TEST_CASE(mbsrtowcs)
TEST_CASE(mbsnrtowcs)
{
mbstate_t state = {};
const char good_chars[] = "\xf0\x9f\x90\x9e\xf0\x9f\x90\x9e";
const char* src;
char const good_chars[] = "\xf0\x9f\x90\x9e\xf0\x9f\x90\x9e";
char const* src;
size_t ret = 0;
// Convert nothing.