From 461105a501550349a5a9998d563b25370834df8b Mon Sep 17 00:00:00 2001 From: Mat M Date: Mon, 26 Feb 2018 00:23:31 -0500 Subject: [PATCH] fuse: simplify checks in fuse_get_reserved_odm and fuse_get_spare_bit (#54) A separate variable isn't particularly necessary here, and given that the type is unsigned, we only need to test the upper bound. This also resolves two -Wtype-limits warnings --- exosphere/src/fuse.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/exosphere/src/fuse.c b/exosphere/src/fuse.c index 62794a366..a25e666c4 100644 --- a/exosphere/src/fuse.c +++ b/exosphere/src/fuse.c @@ -132,23 +132,21 @@ uint32_t fuse_get_bootrom_patch_version(void) /* Read a spare bit register from the shadow cache */ uint32_t fuse_get_spare_bit(uint32_t idx) { - uint32_t spare_bit_val = 0; + if (idx >= 32) { + return 0; + } - if ((idx >= 0) && (idx < 32)) - spare_bit_val = FUSE_CHIP_REGS->FUSE_SPARE_BIT[idx]; - - return spare_bit_val; + return FUSE_CHIP_REGS->FUSE_SPARE_BIT[idx]; } /* Read a reserved ODM register from the shadow cache */ uint32_t fuse_get_reserved_odm(uint32_t idx) { - uint32_t reserved_odm_val = 0; - - if ((idx >= 0) && (idx < 8)) - reserved_odm_val = FUSE_CHIP_REGS->FUSE_RESERVED_ODM[idx]; - - return reserved_odm_val; + if (idx >= 8) { + return 0; + } + + return FUSE_CHIP_REGS->FUSE_RESERVED_ODM[idx]; } /* Derive the Device ID using values in the shadow cache */