Skip to content

Commit f5ad225

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix shadowed variable in gloo/broadcast.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: dmm-fb Differential Revision: D52959045 fbshipit-source-id: 0133b28882b70f0859f7f0ef8d01b972169070f6
1 parent 1e595e4 commit f5ad225

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

gloo/broadcast.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class BroadcastOptions {
2626
}
2727

2828
template <typename T>
29-
void setInput(T* ptr, size_t elements) {
30-
this->elements = elements;
29+
void setInput(T* ptr, size_t elements_2) {
30+
this->elements = elements_2;
3131
this->elementSize = sizeof(T);
32-
this->in = context->createUnboundBuffer(ptr, elements * sizeof(T));
32+
this->in = context->createUnboundBuffer(ptr, elements_2 * sizeof(T));
3333
}
3434

3535
template <typename T>
@@ -40,22 +40,22 @@ class BroadcastOptions {
4040
}
4141

4242
template <typename T>
43-
void setOutput(T* ptr, size_t elements) {
44-
this->elements = elements;
43+
void setOutput(T* ptr, size_t elements_2) {
44+
this->elements = elements_2;
4545
this->elementSize = sizeof(T);
46-
this->out = context->createUnboundBuffer(ptr, elements * sizeof(T));
46+
this->out = context->createUnboundBuffer(ptr, elements_2 * sizeof(T));
4747
}
4848

49-
void setRoot(int root) {
50-
this->root = root;
49+
void setRoot(int root_2) {
50+
this->root = root_2;
5151
}
5252

53-
void setTag(uint32_t tag) {
54-
this->tag = tag;
53+
void setTag(uint32_t tag_2) {
54+
this->tag = tag_2;
5555
}
5656

57-
void setTimeout(std::chrono::milliseconds timeout) {
58-
this->timeout = timeout;
57+
void setTimeout(std::chrono::milliseconds timeout_2) {
58+
this->timeout = timeout_2;
5959
}
6060

6161
protected:

0 commit comments

Comments
 (0)