Skip to content

Commit c82c8b9

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Remove unused-but-set variables in gloo/mpi/example/main_unmanaged.cc +1
Summary: This diff removes a variable that was set, but which was not used. LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused but set variables often indicate a programming mistake, but can also just be unnecessary cruft that harms readability and performance. Removing this variable will not change how your code works, but the unused variable may indicate your code isn't working the way you thought it was. If you feel the diff needs changes before landing, **please commandeer** and make appropriate changes: there are hundreds of these and responding to them individually is challenging. For questions/comments, contact r-barnes. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: palmje Differential Revision: D57793834 fbshipit-source-id: 464397c542c61d6838285d4c90cbbe81767953b3
1 parent 0dd4558 commit c82c8b9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

gloo/mpi/example/main_unmanaged.cc

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

99
#include <cassert>
1010
#include <iostream>
11+
#include <stdexcept>
1112

1213
#include "gloo/mpi/context.h"
1314
#include "gloo/transport/tcp/device.h"
1415
#include "gloo/allreduce_ring.h"
1516

1617
int main(int argc, char** argv) {
17-
int rv;
18-
19-
rv = MPI_Init(&argc, &argv);
20-
assert(rv == MPI_SUCCESS);
18+
auto rv = MPI_Init(&argc, &argv);
19+
if(rv != MPI_SUCCESS) {
20+
throw std::runtime_error("Failed to initialize MPI");
21+
}
2122

2223
// We'll use the TCP transport in this example
2324
auto dev = gloo::transport::tcp::CreateDevice("localhost");
@@ -36,6 +37,9 @@ int main(int argc, char** argv) {
3637
}
3738

3839
rv = MPI_Finalize();
39-
assert(rv == MPI_SUCCESS);
40+
if(rv != MPI_SUCCESS) {
41+
throw std::runtime_error("Failed to Finalize MPI");
42+
}
43+
4044
return 0;
4145
}

0 commit comments

Comments
 (0)