diff options
Diffstat (limited to 'chip/g/loader/main.c')
-rw-r--r-- | chip/g/loader/main.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/chip/g/loader/main.c b/chip/g/loader/main.c index dd538e2c53..985aa34a19 100644 --- a/chip/g/loader/main.c +++ b/chip/g/loader/main.c @@ -63,19 +63,16 @@ void panic_printf(const char *format, ...) /* Returns 1 if version a is newer, 0 otherwise. */ int is_newer_than(const struct SignedHeader *a, const struct SignedHeader *b) { - if (a->epoch_ > b->epoch_) - return 1; - if (a->epoch_ < b->epoch_) - return 0; - if (a->major_ > b->major_) - return 1; - if (a->major_ < b->major_) - return 0; - if (a->minor_ > b->minor_) - return 1; - if (a->minor_ < b->minor_) - return 0; - return 0; + if (a->epoch_ != b->epoch_) + return a->epoch_ > b->epoch_; + if (a->major_ != b->major_) + return a->major_ > b->major_; + if (a->minor_ != b->minor_) + return a->minor_ > b->minor_; + if (a->timestamp_ != b->timestamp_) + return a->timestamp_ > b->timestamp_; + + return 1; /* All else being equal, consider A to be newer. */ } int main(void) @@ -96,11 +93,11 @@ int main(void) * Run from bank a if the versions are equal. */ if (is_newer_than(a, b)) { - first = b; - second = a; - } else { first = a; second = b; + } else { + first = b; + second = a; } if (GREG32(PMU, PWRDN_SCRATCH30) == 0xcafebabe) { /* Launch from the alternate bank first. |