diff options
| author | Stefan Boberg <[email protected]> | 2026-05-05 17:32:57 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-05-05 17:32:57 +0200 |
| commit | 453d8914478d94d2a7e88b5c9712304869b8488b (patch) | |
| tree | 52f7f099ba3a37fceffd8aa2d03c5ddaac0cc8f1 | |
| parent | cleanups (diff) | |
| download | archived-zen-de/opaque-file-handle.tar.xz archived-zen-de/opaque-file-handle.zip | |
work around bug in clang-format v13 by not using #elifde/opaque-file-handle
Pre-commit *is* running clang-format on every commit. It's pinned to `v13.0.1` in `.pre-commit-config.yaml:26`, and clang-format 13 considers `filesystem.cpp` already correctly formatted (replacements XML is empty, `pre_commit run --files` returns Passed).
**The bug:** clang-format 13's `AlignConsecutive{Declarations,Assignments}` does not apply inside `#elif` branches when the matching `#if` branch contains substantial code. `LinuxCloneQueryInterface` lives at line 926, inside `#elif ZEN_PLATFORM_LINUX` — paired with the ~150-line `WindowsCloneQueryInterface` in the `#if ZEN_PLATFORM_WINDOWS` branch above it. That's why only this one class is broken; everything else in the file (including the `#if ZEN_PLATFORM_WINDOWS` branch directly above) aligns fine.
| -rw-r--r-- | src/zencore/filesystem.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp index b314959ab..7f929764b 100644 --- a/src/zencore/filesystem.cpp +++ b/src/zencore/filesystem.cpp @@ -920,8 +920,9 @@ private: uint64_t m_AlignmentSize; DWORD m_TargetVolumeSerialNumber; }; +#endif -#elif ZEN_PLATFORM_LINUX +#if ZEN_PLATFORM_LINUX class LinuxCloneQueryInterface : public CloneQueryInterface { @@ -942,9 +943,9 @@ public: return St.st_dev == m_TargetDevice; } - virtual uint64_t GetClonableRange(uint64_t SourceOffset, - uint64_t TargetOffset, - uint64_t Size, + virtual uint64_t GetClonableRange(uint64_t SourceOffset, + uint64_t TargetOffset, + uint64_t Size, uint64_t& OutPreBytes, uint64_t& OutPostBytes) override { @@ -953,7 +954,7 @@ public: return 0; } - uint64_t PreBytes = (m_AlignmentSize - (SourceOffset % m_AlignmentSize)) % m_AlignmentSize; + uint64_t PreBytes = (m_AlignmentSize - (SourceOffset % m_AlignmentSize)) % m_AlignmentSize; uint64_t PostBytes = (SourceOffset + Size) % m_AlignmentSize; ZEN_ASSERT(Size >= PreBytes + PostBytes); if (Size - (PreBytes + PostBytes) < m_AlignmentSize) @@ -968,8 +969,8 @@ public: return 0; } - OutPreBytes = PreBytes; - OutPostBytes = PostBytes; + OutPreBytes = PreBytes; + OutPostBytes = PostBytes; uint64_t CloneSize = Size - (PreBytes + PostBytes); ZEN_ASSERT(CloneSize % m_AlignmentSize == 0); return CloneSize; @@ -977,10 +978,10 @@ public: virtual bool TryClone(NativeFileHandle SourceNativeHandle, NativeFileHandle TargetNativeHandle, - uint64_t AlignedSourceOffset, - uint64_t AlignedTargetOffset, - uint64_t AlignedSize, - uint64_t TargetFinalSize) override + uint64_t AlignedSourceOffset, + uint64_t AlignedTargetOffset, + uint64_t AlignedSize, + uint64_t TargetFinalSize) override { ZEN_ASSERT_SLOW(CanClone(SourceNativeHandle)); ZEN_ASSERT((AlignedSourceOffset % m_AlignmentSize) == 0); @@ -1004,10 +1005,10 @@ public: } struct file_clone_range Range = {}; - Range.src_fd = SourceFd; - Range.src_offset = AlignedSourceOffset; - Range.src_length = AlignedSize; - Range.dest_offset = AlignedTargetOffset; + Range.src_fd = SourceFd; + Range.src_offset = AlignedSourceOffset; + Range.src_length = AlignedSize; + Range.dest_offset = AlignedTargetOffset; if (ioctl(TargetFd, FICLONERANGE, &Range) != 0) { @@ -1026,7 +1027,7 @@ public: private: uint64_t m_AlignmentSize; - dev_t m_TargetDevice; + dev_t m_TargetDevice; }; #endif // ZEN_PLATFORM_WINDOWS / ZEN_PLATFORM_LINUX |