Fix incorrect order of operations.
This results in an out-of-bounds access (if control_machine was not being intentionally over-alloced to avoid it), the wrong address, and other subtle problems. C's order of operations meant this was resolving as: i = (_backup_index() != -1); which is either 0 or 1. Through sheer luck, this still results in the correct answer for the primary (_backup_index() is -1, and then i = (-1 != -1) is still 0 which is correct), and first backup controller (_backup_index() is 1, and then i = (1 != -1) is still 1 which is also correct), but any further backups controllers will end up with the address of the first backup.
Please register or sign in to comment