auralix / alx-202-af-10-1-auralix-c-lib

GNU General Public License v3.0
0 stars 0 forks source link

General - bool isErr = true and if(isErr) pattern optimization, seems we can just return after relevant line.. #59

Closed tomazvidovic closed 8 months ago

tomazvidovic commented 9 months ago
static void AlxI2c_Periph_EnableClk(AlxI2c* me)
{
    bool isErr = true;

    #if defined(I2C1)
    if (me->hi2c.Instance == I2C1)  { __HAL_RCC_I2C1_CLK_ENABLE(); isErr = false; }
    #endif
    #if defined(I2C2)
    if (me->hi2c.Instance == I2C2)  { __HAL_RCC_I2C2_CLK_ENABLE(); isErr = false; }
    #endif
    #if defined(I2C3)
    if (me->hi2c.Instance == I2C3)  { __HAL_RCC_I2C3_CLK_ENABLE(); isErr = false; }
    #endif
    #if defined(I2C4)
    if (me->hi2c.Instance == I2C4)  { __HAL_RCC_I2C4_CLK_ENABLE(); isErr = false; }
    #endif
    #if defined(I2C5)
    if (me->hi2c.Instance == I2C5)  { __HAL_RCC_I2C5_CLK_ENABLE(); isErr = false; }
    #endif
    #if defined(I2C6)
    if (me->hi2c.Instance == I2C6)  { __HAL_RCC_I2C6_CLK_ENABLE(); isErr = false; }
    #endif

    if(isErr)                       { ALX_I2C_ASSERT(false); }  // We should not get here
}