-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc] lfind_test.cpp: put helpers in an anonymous namespace. #137821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This matches other tests and allows the tests to be built together (as Android is doing).
@llvm/pr-subscribers-libc Author: None (enh-google) ChangesThis matches other tests and allows the tests to be built together (as Android is doing). Full diff: https://github.com/llvm/llvm-project/pull/137821.diff 1 Files Affected:
diff --git a/libc/test/src/search/lfind_test.cpp b/libc/test/src/search/lfind_test.cpp
index 00384f7eec14e..8c67bd4aefe1c 100644
--- a/libc/test/src/search/lfind_test.cpp
+++ b/libc/test/src/search/lfind_test.cpp
@@ -9,10 +9,14 @@
#include "src/search/lfind.h"
#include "test/UnitTest/Test.h"
+namespace {
+
int compar(const void *a, const void *b) {
return *reinterpret_cast<const int *>(a) != *reinterpret_cast<const int *>(b);
}
+};
+
TEST(LlvmLibcLfindTest, SearchHead) {
int list[3] = {1, 2, 3};
size_t len = 3;
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
libc/test/src/search/lfind_test.cpp
Outdated
namespace { | ||
|
||
int compar(const void *a, const void *b) { | ||
return *reinterpret_cast<const int *>(a) != *reinterpret_cast<const int *>(b); | ||
} | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace { | |
int compar(const void *a, const void *b) { | |
return *reinterpret_cast<const int *>(a) != *reinterpret_cast<const int *>(b); | |
} | |
} | |
static int compar(const void *a, const void *b) { | |
return *reinterpret_cast<const int *>(a) != *reinterpret_cast<const int *>(b); | |
} |
Honestly, this is more in-line with LLVM's coding style, but I don't know how much libc
differs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i'd have just used static myself but other llvm-libc tests seemed to have an anonymous namespace...
Is the function supposed to becalled |
that looks weird to me, but that does seem to be used consistently throughout the test, implementation, and header. fwiw, that's also what the original BSD implementation called it. over in bionic's headers, i call it bruce tognazzini had a story in one of his books where someone bought a designer jacket in milan, sent it to the far east to be duplicated, and when the first shipment came back wondered why there was a weird brown mark on the cuff of every single one. they contacted the factory, and they said "that was on the original --- we'll send it back for you to see". turns out they'd copied the accidental cigarette burn too... |
…37821) This matches other tests and allows the tests to be built together (as Android is doing).
…37821) This matches other tests and allows the tests to be built together (as Android is doing).
…37821) This matches other tests and allows the tests to be built together (as Android is doing).
…37821) This matches other tests and allows the tests to be built together (as Android is doing).
…37821) This matches other tests and allows the tests to be built together (as Android is doing).
This matches other tests and allows the tests to be built together (as Android is doing).