Skip to content

0.4.0: sys::in_addr_convertion test fails on s390x / IBM System Z (big-endian) #216

@decathorpe

Description

@decathorpe
---- sys::in_addr_convertion stdout ----
thread 'sys::in_addr_convertion' panicked at 'assertion failed: `(left == right)`
  left: `2130706433`,
 right: `16777343`', src/sys/unix.rs:1450:5

The test passes on on all little-endian architectures I have access to.

  • Looking at the code, the to_in_addr function uses from_ne_bytes (equivalent to big-endian?).
  • According to std sources, Ipv4Addr::octets() returns the bytes in network-endian order, so that's good.

I think the explicitly "shift-constructed" expected u32 value has the wrong byte order for BE systems, which is apparent when looking at the u32s in binary:

left:   01111111 00000000 00000000 00000001
right:  00000001 00000000 00000000 01111111

The "right" one is the "expected" value I get when calculating 127 | 1 << 24 manually on a little-endian system, but the "left" value definitely has the reversed byte order when constructing it manually on a big-endian system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions