michaeljclark / stdendian

(unofficial) proposal for stdendian.h header providing cross-platform endian macros and endian conversion functions.
7 stars 1 forks source link

64-bit parameters wrong throughout #2

Closed natevw closed 3 years ago

natevw commented 3 years ago

Many of your examples show signatures like:

// …snip…
uint32_t be32(uint32_t x);
uint64_t be64(uint32_t x);     // 32 → 64 (?!)

which I think are meant to be:

// …snip…
uint32_t be32(uint32_t x);
uint64_t be64(uint64_t x);    // 64 → 64

The first occurrence I see is uint64_t bswap64(uint32_t x) and this affects most of the notes down through the final uint64_t le64toh(uint32_t x).

natevw commented 3 years ago

I thought this was just the README itself but looks like it also effects a few functions throughout the header — both the docs in the opening comment and the code itself — as well.

michaeljclark commented 3 years ago

Thanks very much!

I hadn't noticed the typo. It's a copy-paste bug for sure. I have used the header but I was not using the BSD wrappers. There are also no tests for the BSD interface. It was present in the simplified interface (be64, le64) which I have been using but only in the comment as I must have spotted it.

Fixed here: https://github.com/michaeljclark/stdendian/commit/2b3be0ff4783a2773d9e5c0414514e88ecd1d879