hv: other: fix "Procedure has more than one exit point"

IEC 61508,ISO 26262 standards highly recommend single-exit rule.

Reduce the count of the "return entries".
Fix the violations which is comply with the cases list below:
1.Function has 2 return entries.
2.The first return entry is used to return the error code of
checking variable whether is valid.

Fix the violations in "if else" format.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Huihuang Shi
2018-11-29 11:10:36 +08:00
committed by wenlingz
parent fe3de67906
commit 10bde520a5
4 changed files with 82 additions and 83 deletions

View File

@@ -81,13 +81,15 @@ static inline void pio_write(uint32_t v, uint16_t addr, size_t sz)
static inline uint32_t pio_read(uint16_t addr, size_t sz)
{
uint32_t ret;
if (sz == 1U) {
return pio_read8(addr);
ret = pio_read8(addr);
} else if (sz == 2U) {
ret = pio_read16(addr);
} else {
ret = pio_read32(addr);
}
if (sz == 2U) {
return pio_read16(addr);
}
return pio_read32(addr);
return ret;
}
/** Writes a 64 bit value to a memory mapped IO device.