davidchisnall / dtc

FreeBSD Device Tree Compiler
18 stars 15 forks source link

Split out consumption of magic number from magic number check #45

Closed kevans91 closed 6 years ago

kevans91 commented 6 years ago

If consumption fails, we cannot trust that 'magic' was populated with anything useful. To compound on this, 'magic' is initialized with 0xd00dfeed. These facts combined meant that piping completely broken or missing output into dtc would always result in an error message like:

Missing magic token in header. Got d00dfeed expected 0xd00dfeed

Which is wrong, since it most certainly did not get d00dfeed. Instead of removing the initialization, just split it out so we have two obviously different error cases: Missing magic token, and incorrect magic token.