In addition to the EOF detection comment:\ The number of midi tracks should come from the `NumTracks` field of the `MThd` chunk, no?\ The infinite for loop would change to ``` for (i = 0; i < NumTracks; i++) ``` and every E_FAIL would be an error. Even if that's due to EOF as that would be a premature EOF (corrupt file).
Tests are not a problem for patch 2. But can you please specify which application relies on that change?\
Just a minor nitpick on patch 2: The commit message contains a typo `dmimi:`.