Replace conditional byte swapping with portable host/LE conversion#2105
Replace conditional byte swapping with portable host/LE conversion#2105Dead2 merged 1 commit intozlib-ng:developfrom
Conversation
59ba4d1 to
983d218
Compare
|
The current naming style follows posix conversion, but another alternative that is probably more readable would be |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2105 +/- ##
============================================
+ Coverage 32.94% 84.54% +51.59%
============================================
Files 75 158 +83
Lines 7716 12945 +5229
Branches 1469 3224 +1755
============================================
+ Hits 2542 10944 +8402
+ Misses 4913 954 -3959
- Partials 261 1047 +786 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughStandardizes endianness handling by introducing explicit LE/BE conversion macros (zendian.h) and replacing conditional BYTE_ORDER/ZSWAP usage across CRC, deflate, and inflate code; removes one local gzip header buffer and an include from a template header. Changes
Sequence Diagram(s)(Skipped — changes are refactorings of endianness handling, not a new multi-component control-flow feature.) Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
WalkthroughStandardizes endianness handling across the codebase by introducing explicit host-to-little-endian and host-to-big-endian conversion macros in zbuild.h, then updating CRC, deflate, and inflate implementations to use these new macros instead of conditional ZSWAP operations. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I don't think the new naming is more readable... At bare minimum it needs some underscores. |
|
|
983d218 to
3999d2e
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
inflate_p.h (1)
8-9: Missing#include "zendian.h"causes build failure.The file uses
ZHTOLE16,ZHTOLE32, andZLE64TOHmacros defined inzendian.h, but does not include this header. This causes the pipeline failure: "Call to undeclared function 'ZLE64TOH'".🐛 Proposed fix
`#include` <stdlib.h> +#include "zendian.h" `#include` "zmemory.h"
41e9330 to
72dab38
Compare
Abreviating "WORD" to "W" makes the two macro names least readable... I have nothing against using numeric bit widths in the other macros as the numbers acts as natural separator. |
72dab38 to
9448a81
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
arch/generic/crc32_chorba_c.c (1)
1-1423: Endianness handling uses portable macros correctly, but the characterization of two distinct strategies is inaccurate.The refactoring correctly replaces conditional byte-swapping with
ZLETOH*/ZHTOLE*macros defined inzendian.h. However, all functions use input-element conversion—they differ only in when it occurs:
- 118960: Delays
ZLETOH64conversion to the final loop; first two loops work with unconvertedz_word_tvalues- 32768 and small variants: Convert each input element with
ZLETOH64/ZLETOH32in their main loopsAll functions correctly convert CRC/state values to LE format via
ZHTOLE64/ZHTOLE32before final buffer operations. The macros properly handle both little-endian and big-endian platforms (expanding to no-ops on LE,ZSWAP*on BE).
mtl1979
left a comment
There was a problem hiding this comment.
After merging assignment with optional byteswap, the following XOR operations can be merged to same line. The macro invocation should not need parentheses around to make order of operations correct, but this should be verified, and if needed the macro invocation should be surrounded by parentheses.
|
Most of the failures on CI are big-endian architectures, so possibly line 49 is bad... |
Yeah I think Coderabbit was wrong on this one. |
It can't really give good suggestions if it doesn't know the naming rules/guidelines for preprocessor macros and the correct macro doesn't already exist... |
a89443d to
ce3c876
Compare
|
CodeCov shows failures most likely due to PR needing rebase, currently there is 2 commits missing from base... |
perhaps, could take what ffmpeg/avutil has for naming |
963fa6b to
499cb82
Compare
|
Found a few more instances to replace. |
499cb82 to
15bfa0e
Compare
|
Rebased. |
|
Thanks! |
No description provided.