Skip to content

Commit 38b927c

Browse files
All [[maybe_unused]]
1 parent fd26016 commit 38b927c

File tree

23 files changed

+51
-33
lines changed

23 files changed

+51
-33
lines changed

libc/test/UnitTest/FPExceptMatcher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace testing {
3131
static thread_local sigjmp_buf jumpBuffer;
3232
static thread_local bool caughtExcept;
3333

34-
static void sigfpeHandler(int /*sig*/) {
34+
static void sigfpeHandler([[maybe_unused]] int sig) {
3535
caughtExcept = true;
3636
siglongjmp(jumpBuffer, -1);
3737
}

libc/test/UnitTest/FPExceptMatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class FPExceptMatcher : public Matcher<bool> {
4343
// Takes ownership of func.
4444
explicit FPExceptMatcher(FunctionCaller *func);
4545

46-
bool match(bool /*unused*/) { return exceptionRaised; }
46+
bool match([[maybe_unused]] bool unused) { return exceptionRaised; }
4747

4848
void explainError() override {
4949
tlog << "A floating point exception should have been raised but it "

libc/test/UnitTest/HermeticTestUtils.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ int atexit(void (*func)(void));
2929
// add_libc_hermetic_test properly. Such that they won't get correct linkage
3030
// against the object containing this function. We create a dummy function that
3131
// always returns 0 to indicate a failure.
32-
[[gnu::weak]] unsigned long getauxval(unsigned long /*id*/) { return 0; }
32+
[[gnu::weak]] unsigned long getauxval([[maybe_unused]] unsigned long id) {
33+
return 0;
34+
}
3335

3436
} // namespace LIBC_NAMESPACE_DECL
3537

@@ -124,7 +126,7 @@ unsigned long __getauxval(unsigned long id) {
124126

125127
} // extern "C"
126128

127-
void *operator new(size_t /*size*/, void *ptr) { return ptr; }
129+
void *operator new([[maybe_unused]] size_t size, void *ptr) { return ptr; }
128130

129131
void *operator new(size_t size) { return malloc(size); }
130132

@@ -136,7 +138,9 @@ void operator delete(void *) {
136138
__builtin_trap();
137139
}
138140

139-
void operator delete(void * /*ptr*/, size_t /*size*/) { __builtin_trap(); }
141+
void operator delete([[maybe_unused]] void *ptr, [[maybe_unused]] size_t size) {
142+
__builtin_trap();
143+
}
140144

141145
// Defining members in the std namespace is not preferred. But, we do it here
142146
// so that we can use it to define the operator new which takes std::align_val_t
@@ -145,10 +149,11 @@ namespace std {
145149
enum class align_val_t : size_t {};
146150
} // namespace std
147151

148-
void operator delete(void * /*mem*/, std::align_val_t) noexcept {
152+
void operator delete([[maybe_unused]] void *mem, std::align_val_t) noexcept {
149153
__builtin_trap();
150154
}
151155

152-
void operator delete(void * /*mem*/, unsigned int, std::align_val_t) noexcept {
156+
void operator delete([[maybe_unused]] void *mem, unsigned int,
157+
std::align_val_t) noexcept {
153158
__builtin_trap();
154159
}

libc/test/UnitTest/LibcDeathTestExecutors.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace LIBC_NAMESPACE_DECL {
2222
namespace testing {
2323

2424
bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
25-
const char *LHSStr, const char * /*RHSStr*/,
25+
const char *LHSStr,
26+
[[maybe_unused]] const char *RHSStr,
2627
internal::Location Loc) {
2728
testutils::ProcessStatus Result =
2829
testutils::invoke_in_subprocess(Func, TIMEOUT_MS);

libc/test/UnitTest/LibcTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct Message {
8181
// A trivial object to catch the Message, this enables custom logging and
8282
// returning from the test function, see LIBC_TEST_SCAFFOLDING_ below.
8383
struct Failure {
84-
void operator=(Message /*msg*/) {}
84+
void operator=([[maybe_unused]] Message msg) {}
8585
};
8686

8787
struct RunContext {

libc/test/integration/src/pthread/pthread_mutex_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ constexpr int MAX = 10000;
2525
pthread_mutex_t mutex;
2626
static int shared_int = START;
2727

28-
void *counter(void * /*arg*/) {
28+
void *counter([[maybe_unused]] void *arg) {
2929
int last_count = START;
3030
while (true) {
3131
LIBC_NAMESPACE::pthread_mutex_lock(&mutex);
@@ -74,7 +74,7 @@ void relay_counter() {
7474
pthread_mutex_t start_lock, step_lock;
7575
bool started, step;
7676

77-
void *stepper(void * /*arg*/) {
77+
void *stepper([[maybe_unused]] void *arg) {
7878
LIBC_NAMESPACE::pthread_mutex_lock(&start_lock);
7979
started = true;
8080
LIBC_NAMESPACE::pthread_mutex_unlock(&start_lock);

libc/test/integration/src/spawn/posix_spawn_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ void spawn_and_wait_for_normal_exit(char **envp) {
4545
ASSERT_EQ(exit_status, 0);
4646
}
4747

48-
TEST_MAIN(int /*argc*/, char ** /*argv*/, char **envp) {
48+
TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
49+
char **envp) {
4950
spawn_and_wait_for_normal_exit(envp);
5051
return 0;
5152
}

libc/test/integration/src/spawn/posix_spawn_test_binary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <string.h>
33
#include <unistd.h>
44

5-
int main(int argc, char ** /*argv*/) {
5+
int main(int argc, [[maybe_unused]] char **argv) {
66
if (argc != 1)
77
return 5;
88
constexpr size_t bufsize = sizeof(TEXT);

libc/test/integration/src/stdio/sprintf_size_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int my_strlen(const char *str) {
3838
return static_cast<int>(other - str);
3939
}
4040

41-
TEST_MAIN(int argc, char **argv, char ** /*envp*/) {
41+
TEST_MAIN(int argc, char **argv, [[maybe_unused]] char **envp) {
4242
ASSERT_EQ(argc, 5);
4343
ASSERT_TRUE(my_streq(argv[1], "%s %c %d"));
4444
ASSERT_EQ(my_strlen(argv[1]), 8);

libc/test/integration/src/stdlib/getenv_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ static bool my_streq(const char *lhs, const char *rhs) {
2727
return *l == '\0' && *r == '\0';
2828
}
2929

30-
TEST_MAIN(int /*argc*/, char ** /*argv*/, char ** /*envp*/) {
30+
TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
31+
[[maybe_unused]] char **envp) {
3132
ASSERT_TRUE(
3233
my_streq(LIBC_NAMESPACE::getenv(""), static_cast<char *>(nullptr)));
3334
ASSERT_TRUE(

0 commit comments

Comments
 (0)