8000 gh-124044: protect macros expansions using `do-while` constructions (WIP) by picnixz · Pull Request #123842 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-124044: protect macros expansions using do-while constructions (WIP) #123842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8fe006f
protect `RETURN_WITH_ERROR` macros expansion via `do { ... } while (0…
picnixz Sep 8, 2024
6629a49
protect `COPY_{NOT_FLAG,FLAG}` macros expansion via `do { ... } while…
picnixz Sep 8, 2024
a4a469e
`Python/ast_opt.c`: protect macros expansion via `do { ... } while (0…
picnixz Sep 8, 2024
a10560a
`Python/ceval_gil.c`: protect macros expansion via `do { ... } while …
picnixz Sep 8, 2024
b478910
`Python/pyhash.c`: protect macros expansion via `do { ... } while (0)…
picnixz Sep 8, 2024
cd3873f
`Python/optimizer.c`: protect macros expansion via `do { ... } while …
picnixz Sep 8, 2024
446ccb5
`Python/perf_jit_trampoline.c`: protect macros expansion via `do { ..…
picnixz Sep 8, 2024
c76137a
`Python/_ssl.c`: protect macros expansion via `do { ... } while (0)` …
picnixz Sep 8, 2024
df70f7a
`Python/specialize.c`: protect macros expansion via `do { ... } while…
picnixz Sep 8, 2024
1acfac6
`Python/dtoa.c`: protect macros expansion via `do { ... } while (0)` …
picnixz Sep 8, 2024
7050840
`Objects/sliceobject.c`: protect macros expansion via `do { ... } whi…
picnixz Sep 8, 2024
d1942fa
`Objects/memoryview.c`: protect macros expansion via `do { ... } whil…
picnixz Sep 8, 2024
e195b55
`Objects/dictobject.c`: protect macros expansion via `do { ... } whil…
picnixz Sep 8, 2024
1b65e98
`Modules/posixmodule.c`: protect macros expansion via `do { ... } whi…
picnixz Sep 8, 2024
e32c48a
`Modules/getaddrinfo.c`: protect macros expansion via `do { ... } whi…
picnixz Sep 8, 2024
44474eb
`Modules/_testcapi/monitoring.c`: protect macros expansion via `do { …
picnixz Sep 8, 2024
ae3adff
`Modules/ctypes/_ctypes.c`: protect macros expansion via `do { ... } …
picnixz Sep 9, 2024
0baba9c
`Modules/_csv.c`: protect macros expansion via `do { ... } while (0)`…
picnixz Sep 9, 2024
2199509
`Modules/_asynciomodule.c`: protect macros expansion via `do { ... } …
picnixz Sep 9, 2024
b0fbdde
`Modules/_testlimitedcapi/unicode.c`: protect macros expansion via `d…
picnixz Sep 9, 2024
8eda720
`Modules/_testcapi/mem.c`: protect macros expansion via `do { ... } w…
picnixz Sep 9, 2024
c495a87
`Modules/_io/textio.c`: protect macros expansion via `do { ... } whil…
picnixz Sep 9, 2024
88b98dc
`Modules/_io/stringio.c`: protect macros expansion via `do { ... } wh…
picnixz Sep 9, 2024
3a97448
`Modules/_io/bytesio.c`: protect macros expansion via `do { ... } whi…
picnixz Sep 9, 2024
160a6c1
`Modules/_io/bufferedio.c`: protect macros expansion via `do { ... } …
picnixz Sep 9, 2024
5c90db8
`Modules/_ctypes/cfield.c`: protect macros expansion via `do { ... } …
picnixz Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
protect RETURN_WITH_ERROR macros expansion via `do { ... } while (0…
…)` constructions

This affects `Python/{assemble,flowgraph,instruction_sequence}.c`.
  • Loading branch information
picnixz committed Sep 9, 2024
commit 8fe006fc40e29a67e0ec9d2986612544185576e2
8 changes: 5 additions & 3 deletions Python/assemble.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
#define ERROR -1

#define RETURN_IF_ERROR(X) \
if ((X) < 0) { \
return ERROR; \
}
do { \
if ((X) < 0) { \
return ERROR; \
} \
} while (0) \

typedef _Py_SourceLocation location;
typedef _PyInstruction instruction;
Expand Down
8 changes: 5 additions & 3 deletions Python/flowgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
#define ERROR -1

#define RETURN_IF_ERROR(X) \
if ((X) == -1) { \
return ERROR; \
}
do { \
if ((X) == -1) { \
return ERROR; \
} \
} while (0) \

#define DEFAULT_BLOCK_SIZE 16

Expand Down
8 changes: 5 additions & 3 deletions Python/instruction_sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ typedef _Py_SourceLocation location;
#define ERROR -1

#define RETURN_IF_ERROR(X) \
if ((X) == -1) { \
return ERROR; \
}
do { \
if ((X) == -1) { \
return ERROR; \
} \
} while (0) \

static int
instr_sequence_next_inst(instr_sequence *seq) {
Expand Down
0