mdns: fix build on big-endian ports#409
Open
tinic wants to merge 1 commit into
Open
mdns: fix build on big-endian ports#409tinic wants to merge 1 commit into
tinic wants to merge 1 commit into
Conversation
nxd_mdns.c uses NX_CHANGE_USHORT_ENDIAN() as an expression:
*(USHORT *)(packet_ptr -> nx_packet_prepend_ptr + NX_MDNS_FLAGS_OFFSET)
|= NX_CHANGE_USHORT_ENDIAN(tc_bit);
Big-endian ports define that macro as empty, so it expands to
"*(USHORT *)(...) |= ;" and addons/mdns fails to compile on every
big-endian target.
It goes unnoticed on little-endian because those ports define the macro as
an assignment -- a = (((a >> 8) | (a << 8)) & 0xFFFF) -- which has a value
and so parses in expression position. Every other call site in the
repository uses the macro as a statement, which is what an
unconditionally-empty definition requires; see for example
test/regression/ptp_test/netx_ptp_utility.c. This is the only expression
use.
Swap in place, then OR, which keeps the macro used as a statement.
Verified against both upstream definitions: with the big-endian (empty)
definition the original fails to compile and this compiles; with the
little-endian definition both produce the same flags word, 0x0002.
Found while building addons/mdns for m68k AmigaOS.
Signed-off-by: Tinic Uro <tinicuro@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nxd_mdns.c uses NX_CHANGE_USHORT_ENDIAN() as an expression:
Big-endian ports define that macro as empty, so it expands to "*(USHORT *)(...) |= ;" and addons/mdns fails to compile on every big-endian target.
It goes unnoticed on little-endian because those ports define the macro as an assignment -- a = (((a >> 8) | (a << 8)) & 0xFFFF) -- which has a value and so parses in expression position. Every other call site in the repository uses the macro as a statement, which is what an unconditionally-empty definition requires; see for example test/regression/ptp_test/netx_ptp_utility.c. This is the only expression use.
Swap in place, then OR, which keeps the macro used as a statement.
Verified against both upstream definitions: with the big-endian (empty) definition the original fails to compile and this compiles; with the little-endian definition both produce the same flags word, 0x0002.
Found while building addons/mdns for m68k AmigaOS.