Skip to content

Commit 8c30856

Browse files
fix warnings in echion
1 parent e850622 commit 8c30856

File tree

8 files changed

+158
-39
lines changed

8 files changed

+158
-39
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Language: Cpp
2+
BasedOnStyle: Google
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlines: Left
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: true
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: Empty
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: Yes
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BraceWrapping:
23+
AfterClass: true
24+
AfterControlStatement: true
25+
AfterEnum: true
26+
AfterFunction: true
27+
AfterNamespace: true
28+
AfterStruct: true
29+
AfterUnion: true
30+
BeforeCatch: true
31+
BeforeElse: true
32+
IndentBraces: false
33+
BreakBeforeBinaryOperators: None
34+
BreakBeforeBraces: Custom
35+
BreakBeforeInheritanceComma: false
36+
BreakInheritanceList: BeforeColon
37+
BreakBeforeTernaryOperators: true
38+
BreakConstructorInitializersBeforeComma: false
39+
BreakConstructorInitializers: BeforeColon
40+
BreakAfterJavaFieldAnnotations: false
41+
BreakStringLiterals: true
42+
ColumnLimit: 100
43+
CommentPragmas: '^ IWYU pragma:'
44+
CompactNamespaces: false
45+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
46+
ConstructorInitializerIndentWidth: 4
47+
ContinuationIndentWidth: 4
48+
Cpp11BracedListStyle: true
49+
DerivePointerAlignment: false
50+
DisableFormat: false
51+
ExperimentalAutoDetectBinPacking: false
52+
FixNamespaceComments: true
53+
ForEachMacros:
54+
- foreach
55+
- Q_FOREACH
56+
- BOOST_FOREACH
57+
IncludeBlocks: Preserve
58+
IncludeCategories:
59+
- Regex: '^<.*\.h>'
60+
Priority: 1
61+
- Regex: '^<.*'
62+
Priority: 2
63+
- Regex: '.*'
64+
Priority: 3
65+
IncludeIsMainRegex: '([-_](test|unittest))?$'
66+
IndentCaseLabels: true
67+
IndentPPDirectives: None
68+
IndentWidth: 4
69+
IndentWrappedFunctionNames: false
70+
JavaScriptQuotes: Leave
71+
JavaScriptWrapImports: true
72+
KeepEmptyLinesAtTheStartOfBlocks: false
73+
MacroBlockBegin: ''
74+
MacroBlockEnd: ''
75+
MaxEmptyLinesToKeep: 2
76+
NamespaceIndentation: None
77+
ObjCBinPackProtocolList: Never
78+
ObjCBlockIndentWidth: 4
79+
ObjCSpaceAfterProperty: false
80+
ObjCSpaceBeforeProtocolList: true
81+
PenaltyBreakAssignment: 2
82+
PenaltyBreakBeforeFirstCallParameter: 1
83+
PenaltyBreakComment: 300
84+
PenaltyBreakFirstLessLess: 120
85+
PenaltyBreakString: 1000
86+
PenaltyBreakTemplateDeclaration: 10
87+
PenaltyExcessCharacter: 1000000
88+
PenaltyReturnTypeOnItsOwnLine: 200
89+
PointerAlignment: Left
90+
ReflowComments: true
91+
SortIncludes: true
92+
SortUsingDeclarations: true
93+
SpaceAfterCStyleCast: false
94+
SpaceAfterTemplateKeyword: true
95+
SpaceBeforeAssignmentOperators: true
96+
SpaceBeforeCpp11BracedList: false
97+
SpaceBeforeCtorInitializerColon: true
98+
SpaceBeforeInheritanceColon: true
99+
SpaceBeforeParens: ControlStatements
100+
SpaceBeforeRangeBasedForLoopColon: true
101+
SpaceInEmptyParentheses: false
102+
SpacesBeforeTrailingComments: 2
103+
SpacesInAngles: false
104+
SpacesInContainerLiterals: false
105+
SpacesInCStyleCastParentheses: false
106+
SpacesInParentheses: false
107+
SpacesInSquareBrackets: false
108+
Standard: Cpp11
109+
TabWidth: 4
110+
UseTab: Never

ddtrace/internal/datadog/profiling/echion/echion/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static PyObject* set_memory(PyObject* Py_UNUSED(m), PyObject* args)
8383
}
8484

8585
// ----------------------------------------------------------------------------
86-
static PyObject* set_native(PyObject* Py_UNUSED(m), PyObject* args)
86+
static PyObject* set_native(PyObject* Py_UNUSED(m), PyObject* Py_UNUSED(args))
8787
{
8888
#ifndef UNWIND_NATIVE_DISABLE
8989
int new_native;

ddtrace/internal/datadog/profiling/echion/echion/greenlets.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ inline int GreenletInfo::unwind(PyObject* frame, PyThreadState* tstate, FrameSta
5353
// TODO: Invalid frame
5454
return 0;
5555

56-
frame_addr = (PyObject*)cframe.current_frame;
56+
frame_addr = reinterpret_cast<PyObject*>(cframe.current_frame);
5757
}
5858
else
5959
{
6060
frame_addr = reinterpret_cast<PyObject*>(reinterpret_cast<struct _frame*>(frame)->f_frame);
6161
}
6262

6363
#else // Python < 3.11
64-
frame_addr = frame == Py_None ? (PyObject*)tstate->frame : frame;
64+
frame_addr = frame == Py_None ? reinterpret_cast<PyObject*>(tstate->frame) : frame;
6565
#endif
6666
auto count = unwind_frame(frame_addr, stack);
6767

ddtrace/internal/datadog/profiling/echion/echion/memory.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ class MemoryTable : public std::unordered_map<void*, MemoryTableEntry>
9393
// ------------------------------------------------------------------------
9494
void link(void* address, FrameStack::Key stack, size_t size)
9595
{
96-
std::lock_guard<std::mutex> lock(this->lock);
96+
std::lock_guard<std::mutex> guard(this->lock);
9797

9898
this->emplace(address, MemoryTableEntry{stack, size});
9999
}
100100

101101
// ------------------------------------------------------------------------
102102
std::optional<MemoryTableEntry> unlink(void* address)
103103
{
104-
std::lock_guard<std::mutex> lock(this->lock);
104+
std::lock_guard<std::mutex> guard(this->lock);
105105

106106
auto it = this->find(address);
107107

@@ -126,7 +126,7 @@ class StackStats
126126
// ------------------------------------------------------------------------
127127
void inline update(PyThreadState* tstate, FrameStack::Key stack, size_t size)
128128
{
129-
std::lock_guard<std::mutex> lock(this->lock);
129+
std::lock_guard<std::mutex> guard(this->lock);
130130

131131
auto stack_entry = map.find(stack);
132132

@@ -154,7 +154,7 @@ class StackStats
154154
// ------------------------------------------------------------------------
155155
void inline update(MemoryTableEntry& entry)
156156
{
157-
std::lock_guard<std::mutex> lock(this->lock);
157+
std::lock_guard<std::mutex> guard(this->lock);
158158

159159
auto stack_entry = map.find(entry.stack);
160160

@@ -165,7 +165,7 @@ class StackStats
165165
// ------------------------------------------------------------------------
166166
void flush()
167167
{
168-
std::lock_guard<std::mutex> lock(this->lock);
168+
std::lock_guard<std::mutex> guard(this->lock);
169169

170170
for (auto& entry : map)
171171
{
@@ -182,7 +182,7 @@ class StackStats
182182
// ------------------------------------------------------------------------
183183
void clear()
184184
{
185-
std::lock_guard<std::mutex> lock(this->lock);
185+
std::lock_guard<std::mutex> guard(this->lock);
186186

187187
map.clear();
188188
}

ddtrace/internal/datadog/profiling/echion/echion/stacks.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ static size_t unwind_frame(PyObject* frame_addr, FrameStack& stack)
137137
break;
138138
}
139139

140-
if (maybe_frame->get().name == StringTable::C_FRAME) {
140+
if (maybe_frame->get().name == StringTable::C_FRAME)
141+
{
141142
continue;
142143
}
143144

@@ -164,11 +165,13 @@ static size_t unwind_frame_unsafe(PyObject* frame, FrameStack& stack)
164165
// See the comment in unwind_frame()
165166
while (current_frame != NULL)
166167
{
167-
if (reinterpret_cast<_PyInterpreterFrame*>(current_frame)->f_executable->ob_type == &PyCode_Type)
168+
if (reinterpret_cast<_PyInterpreterFrame*>(current_frame)->f_executable->ob_type ==
169+
&PyCode_Type)
168170
{
169171
break;
170172
}
171-
current_frame = reinterpret_cast<PyObject*>(reinterpret_cast<_PyInterpreterFrame*>(current_frame)->previous);
173+
current_frame = reinterpret_cast<PyObject*>(
174+
reinterpret_cast<_PyInterpreterFrame*>(current_frame)->previous);
172175
}
173176

174177
if (current_frame == NULL)
@@ -183,7 +186,8 @@ static size_t unwind_frame_unsafe(PyObject* frame, FrameStack& stack)
183186
stack.push_back(Frame::get(current_frame));
184187

185188
#if PY_VERSION_HEX >= 0x030b0000
186-
current_frame = reinterpret_cast<PyObject*>(reinterpret_cast<_PyInterpreterFrame*>(current_frame)->previous);
189+
current_frame = reinterpret_cast<PyObject*>(
190+
reinterpret_cast<_PyInterpreterFrame*>(current_frame)->previous);
187191
#else
188192
current_frame = (PyObject*)((PyFrameObject*)current_frame)->f_back;
189193
#endif
@@ -217,9 +221,9 @@ static void unwind_python_stack(PyThreadState* tstate, FrameStack& stack)
217221
// TODO: Invalid frame
218222
return;
219223

220-
PyObject* frame_addr = (PyObject*)cframe.current_frame;
224+
PyObject* frame_addr = reinterpret_cast<PyObject*>(cframe.current_frame);
221225
#else // Python < 3.11
222-
PyObject* frame_addr = (PyObject*)tstate->frame;
226+
PyObject* frame_addr = reinterpret_cast<PyObject*>(tstate->frame);
223227
#endif
224228
unwind_frame(frame_addr, stack);
225229
}
@@ -257,11 +261,11 @@ static void unwind_python_stack(PyThreadState* tstate)
257261
}
258262

259263
// ----------------------------------------------------------------------------
260-
static Result<void> interleave_stacks(FrameStack& python_stack)
264+
static Result<void> interleave_stacks(FrameStack& cur_python_stack)
261265
{
262266
interleaved_stack.clear();
263267

264-
auto p = python_stack.rbegin();
268+
auto p = cur_python_stack.rbegin();
265269
// The last two frames are usually the signal trampoline and the signal
266270
// handler. We skip them.
267271
for (auto n = native_stack.rbegin(); n != native_stack.rend() - 2; ++n)
@@ -277,7 +281,7 @@ static Result<void> interleave_stacks(FrameStack& python_stack)
277281
const auto& name = maybe_name->get();
278282
if (name.find("PyEval_EvalFrameDefault") != std::string::npos)
279283
{
280-
if (p == python_stack.rend())
284+
if (p == cur_python_stack.rend())
281285
{
282286
// We expected a Python frame but we found none, so we report
283287
// the native frame instead.
@@ -290,7 +294,7 @@ static Result<void> interleave_stacks(FrameStack& python_stack)
290294
// function that calls the Python code.
291295
#if PY_VERSION_HEX >= 0x030b0000
292296
int cframe_count = 0;
293-
while (p != python_stack.rend())
297+
while (p != cur_python_stack.rend())
294298
{
295299
// The Python stack will start with an entry frame at the top.
296300
// We stop popping at the next entry frame.
@@ -309,7 +313,7 @@ static Result<void> interleave_stacks(FrameStack& python_stack)
309313
interleaved_stack.push_front(native_frame);
310314
}
311315

312-
if (p != python_stack.rend())
316+
if (p != cur_python_stack.rend())
313317
{
314318
std::cerr << "Python stack not empty after interleaving!" << std::endl;
315319
while (p != python_stack.rend())
@@ -345,7 +349,7 @@ class StackTable
345349
// ------------------------------------------------------------------------
346350
FrameStack::Key inline store(FrameStack::Ptr stack)
347351
{
348-
std::lock_guard<std::mutex> lock(this->lock);
352+
std::lock_guard<std::mutex> guard(this->lock);
349353

350354
auto stack_key = stack->key();
351355

@@ -365,15 +369,15 @@ class StackTable
365369
// ------------------------------------------------------------------------
366370
FrameStack& retrieve(FrameStack::Key stack_key)
367371
{
368-
std::lock_guard<std::mutex> lock(this->lock);
372+
std::lock_guard<std::mutex> guard(this->lock);
369373

370374
return *table.find(stack_key)->second;
371375
}
372376

373377
// ------------------------------------------------------------------------
374378
void clear()
375379
{
376-
std::lock_guard<std::mutex> lock(this->lock);
380+
std::lock_guard<std::mutex> guard(this->lock);
377381

378382
table.clear();
379383
}

ddtrace/internal/datadog/profiling/echion/echion/strings.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ static std::unique_ptr<unsigned char[]> pybytes_to_bytes_and_size(PyObject* byte
3737
return nullptr;
3838

3939
auto data = std::make_unique<unsigned char[]>(*size);
40-
if (copy_generic(reinterpret_cast<char*>(bytes_addr) + offsetof(PyBytesObject, ob_sval), data.get(), *size))
40+
if (copy_generic(reinterpret_cast<char*>(bytes_addr) + offsetof(PyBytesObject, ob_sval),
41+
data.get(), *size))
4142
return nullptr;
4243

4344
return data;
@@ -55,8 +56,10 @@ static Result<std::string> pyunicode_to_utf8(PyObject* str_addr)
5556
if (ascii.state.kind != 1)
5657
return ErrorKind::PyUnicodeError;
5758

58-
const char* data = ascii.state.compact ? reinterpret_cast<const char*>(reinterpret_cast<const uint8_t*>(str_addr) + sizeof(ascii))
59-
: static_cast<const char*>(str._base.utf8);
59+
const char* data = ascii.state.compact
60+
? reinterpret_cast<const char*>(
61+
reinterpret_cast<const uint8_t*>(str_addr) + sizeof(ascii))
62+
: static_cast<const char*>(str._base.utf8);
6063
if (data == NULL)
6164
return ErrorKind::PyUnicodeError;
6265

ddtrace/internal/datadog/profiling/echion/echion/tasks.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ inline Result<GenInfo::Ptr> GenInfo::create(PyObject* gen_addr)
8686
// The frame follows the generator object
8787
auto frame = (gen.gi_frame_state == FRAME_CLEARED)
8888
? NULL
89-
: reinterpret_cast<PyObject*>(reinterpret_cast<char*>(gen_addr) + offsetof(PyGenObject, gi_iframe));
89+
: reinterpret_cast<PyObject*>(reinterpret_cast<char*>(gen_addr) +
90+
offsetof(PyGenObject, gi_iframe));
9091
#else
9192
auto frame = (PyObject*)gen.gi_frame;
9293
#endif
@@ -194,7 +195,8 @@ inline Result<TaskInfo::Ptr> TaskInfo::create(TaskObj* task_addr)
194195
TaskInfo::Ptr waiter = nullptr;
195196
if (task.task_fut_waiter)
196197
{
197-
auto maybe_waiter = TaskInfo::create(reinterpret_cast<TaskObj*>(task.task_fut_waiter)); // TODO: Make lazy?
198+
auto maybe_waiter =
199+
TaskInfo::create(reinterpret_cast<TaskObj*>(task.task_fut_waiter)); // TODO: Make lazy?
198200
if (maybe_waiter)
199201
{
200202
waiter = std::move(*maybe_waiter);
@@ -313,10 +315,10 @@ inline size_t TaskInfo::unwind(FrameStack& stack)
313315
std::stack<PyObject*> coro_frames;
314316

315317
// Unwind the coro chain
316-
for (auto coro = this->coro.get(); coro != NULL; coro = coro->await.get())
318+
for (auto py_coro = this->coro.get(); py_coro != NULL; py_coro = py_coro->await.get())
317319
{
318-
if (coro->frame != NULL)
319-
coro_frames.push(coro->frame);
320+
if (py_coro->frame != NULL)
321+
coro_frames.push(py_coro->frame);
320322
}
321323

322324
int count = 0;

0 commit comments

Comments
 (0)