Skip to content

Commit 4b2b39e

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix shadowed variable in gloo/allgatherv.h
Summary: Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so. This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug. **What's a shadowed variable?** Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs. This diff fixes such an issue by renaming the variable. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: palmje Differential Revision: D52582840 fbshipit-source-id: 96890005a4a21a1ce15a9c9fb2dcc3524cefab45
1 parent fb4bbba commit 4b2b39e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

gloo/allgatherv.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ class AllgathervOptions {
2424
}
2525

2626
template <typename T>
27-
void setInput(T* ptr, size_t elements) {
28-
setInput(static_cast<void*>(ptr), elements, sizeof(T));
27+
void setInput(T* ptr, size_t elements_2) {
28+
setInput(static_cast<void*>(ptr), elements_2, sizeof(T));
2929
}
3030

3131
template <typename T>
3232
void setOutput(
3333
std::unique_ptr<transport::UnboundBuffer> buf,
34-
std::vector<size_t> elements) {
35-
setOutput(std::move(buf), std::move(elements), sizeof(T));
34+
std::vector<size_t> elements_2) {
35+
setOutput(std::move(buf), std::move(elements_2), sizeof(T));
3636
}
3737

3838
template <typename T>
39-
void setOutput(T* ptr, std::vector<size_t> elements) {
40-
setOutput(static_cast<void*>(ptr), std::move(elements), sizeof(T));
39+
void setOutput(T* ptr, std::vector<size_t> elements_2) {
40+
setOutput(static_cast<void*>(ptr), std::move(elements_2), sizeof(T));
4141
}
4242

4343
void setTag(uint32_t tag) {

0 commit comments

Comments
 (0)