8000 Rename macros. · python/cpython@f3fcea1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3fcea1

Browse files
committed
Rename macros.
1 parent a3564a5 commit f3fcea1

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

Modules/faulthandler.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,37 +222,40 @@ faulthandler_stack_dump_impl(int fd)
222222
{
223223
#define BACKTRACE_SIZE 128
224224
#define TRACEBACK_ENTRY_MAX_SIZE 256
225-
void *callstack[SIZE];
226-
int frames = backtrace(callstack, SIZE);
227-
char **strings = backtrace_symbols(callstack, SIZE);
225+
void *callstack[BACKTRACE_SIZE];
226+
int frames = backtrace(callstack, BACKTRACE_SIZE);
227+
char **strings = backtrace_symbols(callstack, BACKTRACE_SIZE);
228228
if (strings == NULL) {
229229
PUTS(fd, " <failed to get stack trace>");
230230
}
231231
else {
232232
for (int i = 0; i < frames; ++i) {
233-
char entry_str[ENTRY_SIZE];
234-
snprintf(entry_str, ENTRY_SIZE, " %s\n", strings[i]);
233+
char entry_str[TRACEBACK_ENTRY_MAX_SIZE];
234+
snprintf(entry_str, TRACEBACK_ENTRY_MAX_SIZE, " %s\n", strings[i]);
235235
size_t length = strlen(entry_str) + 1;
236-
if (length == ENTRY_SIZE)
237-
{
236+
if (length == TRACEBACK_ENTRY_MAX_SIZE) {
238237
/* We exceeded the size, make it look prettier */
239238

240-
// Add ellipsis to last 3 characters (but before the newline and null terminator)
241-
for (int x = 0; x < 3; ++x)
242-
entry_str[ENTRY_SIZE - (x + 3)] = '.';
239+
// Add ellipsis to last 3 characters
240+
entry_str[TRACEBACK_ENTRY_MAX_SIZE - 5] = '.';
241+
entry_str[TRACEBACK_ENTRY_MAX_SIZE - 4] = '.';
242+
entry_str[TRACEBACK_ENTRY_MAX_SIZE - 3] = '.';
243+
244+
// Ensure trailing newline
245+
entry_str[TRACEBACK_ENTRY_MAX_SIZE - 2] = '\n';
243246

244-
entry_str[ENTRY_SIZE - 2] = '\n';
245-
entry_str[ENTRY_SIZE - 1] = '\0';
247+
// Ensure that it's null-terminated
248+
entry_str[TRACEBACK_ENTRY_MAX_SIZE - 1] = '\0';
246249
}
247250
_Py_write_noraise(fd, entry_str, length);
248251
}
249252

250-
if (frames == SIZE) {
253+
if (frames == BACKTRACE_SIZE) {
251254
PUTS(fd, " <truncated rest of calls>");
252255
}
253256
}
254-
#undef ENTRY_SIZE
255-
#undef SIZE
257+
#undef BACKTRACE_SIZE
258+
#undef TRACEBACK_ENTRY_MAX_SIZE
256259
}
257260
#else
258261
static void

0 commit comments

Comments
 (0)
0