3 ms·
What is the reason for the weird `{ code };` blocks everywhere and is the below code machine generated? ```c ((PageSize) (chunk->pageSize -
by ntoslinux 7mo ago
What is the reason for the weird `{ code };` blocks everywhere and is the below code machine generated?
```c
((PageSize)
(chunk->pageSize -
((PageSize)
((PageSize) ((PageSize) (sizeof(Page) + (sizeof(struct _Block))) + (PageSize) ((sizeof(double)) - 1u)) &
((PageSize) (~((PageSize) ((sizeof(double)) - 1u)))))) -
((PageSize)
((PageSize)
((PageSize) ((sizeof(FreeBlock) + sizeof(PageSize))) +
(PageSize) (((((sizeof(double)) >
(4)) ? (sizeof(double)) : (4))) -
```
- bitbasher 7mo agoThere's a lot of code in the file that is questionable to say the least. There are unnecessary blocks ( { ... }; ) of code with unnecessary semicolons that don't serve any logical purpose. My hunch tells me it may be the result of macro-expansion in C (cc -E ...), etc. So it's likely there's a larger code base with multiple files and they expanded it into a one large C file (sometimes called an amalgamation build) and called it a day. By they, I mean the OP, a script or an AI (or all three).
- motbus3 7mo agoExactly my thought... This look like a clean room implementation situation
- deleted 7mo ago[deleted]
- mzajc 7mo agoWorse yet, there's several places with empty code blocks, eg. [0] and [1]. Even without that, the formatting contains so much unnecessary whitespace, newlines, casts, etc; I'm not sure why, given the already massive source file. How do you even fit [2] on a screen? [0]: https://github.com/xtellect/spaces/blob/422dbba85b5a7e9a209aaab2e9ac19c892528d39/spaces.c#L4937-L4938 https://github.com/xtellect/spaces/blob/422dbba85b5a7e9a209a... [1]: https://github.com/xtellect/spaces/blob/422dbba85b5a7e9a209aaab2e9ac19c892528d39/spaces.c#L4834-L4835 https://github.com/xtellect/spaces/blob/422dbba85b5a7e9a209a... [2]: https://github.com/xtellect/spaces/blob/422dbba85b5a7e9a209aaab2e9ac19c892528d39/spaces.c#L5146-L5153 https://github.com/xtellect/spaces/blob/422dbba85b5a7e9a209a...