News for hackers. Stuff that matters.
Re:Have you ever hurt yourself from your own code? by null0pointer on Wednesday May 26, 2021 @09:01PM (#27298126)
Is there a reason why you might want to mix endianness within a file format? Wouldn't it just be extremely error prone as demonstrated in the article?
Re:Have you ever hurt yourself from your own code? by JonathonW on Wednesday May 26, 2021 @09:44PM (#27298420)
The WAV format is not mixed-endian; everything that’s actually a number is little-endian.

The fields the diagram in the article marks as “big endian” are ASCII text— four-byte strings with specific content (“RIFF” for the first ChunkID, “WAVE” for the Format, etc.). If you wanted to treat those as integers in your code, you’d need to treat them as big-endian so their byte order doesn’t get reversed, but they’re really four-byte sequences, not numbers.

Re:Have you ever hurt yourself from your own code? by AnIdiotOnTheNet on Wednesday May 26, 2021 @10:06PM (#27298548)
But they could have just as easily said the integer value for "WAVE" was 0x45564157 in LE and been perfectly consistent.
Re:Have you ever hurt yourself from your own code? by gizmo686 on Wednesday May 26, 2021 @10:36PM (#27298717)
I've had this come up with composite data formats. If your data formats includes already existing data formats and they do not all agree on an endianness you are basically stuck with being inconsistent about it.
Re:Have you ever hurt yourself from your own code? by its_nikita on Wednesday May 26, 2021 @09:07PM (#27298160)
Yeah I was kind of confused about this when I was reading through the spec trying to figure out what went wrong. I wanted to touch on this in the blog post, but I wasn't able to find a good resource explaining the advantage for mixing endianness in a file format.
Re:Have you ever hurt yourself from your own code? by AnIdiotOnTheNet on Wednesday May 26, 2021 @10:01PM (#27298520)
Because the important thing about those fields is that they aren't really big endian at all, they're clearly ASCII characters. Why the spec you have decided to say they were big endian is beyond me.
Re:Have you ever hurt yourself from your own code? by cratermoon on Wednesday May 26, 2021 @09:14PM (#27298212)
Because Microsoft.
Re:Have you ever hurt yourself from your own code? by imoverclocked on Wednesday May 26, 2021 @09:39PM (#27298385)
Well IBM+Microsoft but really... because 90s and x86.
Re:Have you ever hurt yourself from your own code? by seoaeu on Wednesday May 26, 2021 @09:48PM (#27298437)
Obviously not ideal, but it could for instance come up when the file format has one overall endianness but wants to include fragments of data conventionally encoded with the opposite endianness. Trivial example would be a .tar file containing an assortment of other files, but this would also include say embedding network endian data or images within a larger file that contains other data.