diff --git a/ta-lib-rt/c/src/ta_func/ta_ATR.c b/ta-lib-rt/c/src/ta_func/ta_ATR.c index db006c65..d94e087f 100644 --- a/ta-lib-rt/c/src/ta_func/ta_ATR.c +++ b/ta-lib-rt/c/src/ta_func/ta_ATR.c @@ -581,18 +581,16 @@ double tempReal, tempATR; /**** END GENCODE SECTION 9 - DO NOT DELETE THIS LINE ****/ { /* insert local variable here */ - if( STATE_P.optInTimePeriod <= 1 ) - { - /* No smoothing needed. Just do a TRANGE. */ - return FUNCTION_CALL_STATE_FREE(TRANGE)( (struct TA_TRANGE_State**) &STATE_P.StateTRANGE); - } TA_RetCode retCode; retCode = FUNCTION_CALL_STATE_FREE(TRANGE)( (struct TA_TRANGE_State**) &STATE_P.StateTRANGE ); if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode; - else retCode = FUNCTION_CALL_STATE_FREE(SMA)( (struct TA_SMA_State**) &STATE_P.StateSMA ); - if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode; + + if( STATE_P.optInTimePeriod > 1 ) { + retCode = FUNCTION_CALL_STATE_FREE(SMA)( (struct TA_SMA_State**) &STATE_P.StateSMA ); + if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode; + } /**** START GENCODE SECTION 10 - DO NOT DELETE THIS LINE ****/ /* Generated */ diff --git a/ta-lib-rt/c/src/ta_func/ta_MA.c b/ta-lib-rt/c/src/ta_func/ta_MA.c index f0e7067d..7e046464 100644 --- a/ta-lib-rt/c/src/ta_func/ta_MA.c +++ b/ta-lib-rt/c/src/ta_func/ta_MA.c @@ -709,12 +709,10 @@ if( STATE_P.optInTimePeriod != 1 ) default: retValue = ENUM_VALUE(RetCode,TA_BAD_PARAM, BadParam); } -} else { - return ENUM_VALUE(RetCode,TA_SUCCESS,Success); -} -if (retValue != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) - return retValue; + if (retValue != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) + return retValue; +} /**** START GENCODE SECTION 10 - DO NOT DELETE THIS LINE ****/ /* Generated */ diff --git a/ta-lib-rt/c/src/tools/ta_regtest/ta_test_func/test_candlestick.c b/ta-lib-rt/c/src/tools/ta_regtest/ta_test_func/test_candlestick.c index f5b9395c..7e36a74d 100644 --- a/ta-lib-rt/c/src/tools/ta_regtest/ta_test_func/test_candlestick.c +++ b/ta-lib-rt/c/src/tools/ta_regtest/ta_test_func/test_candlestick.c @@ -756,7 +756,7 @@ static ErrorNumber do_test_state( const TA_History *history, { TA_RangeTestParam testParam; ErrorNumber errNb; - TA_RetCode retCode; + TA_RetCode retCode = TA_SUCCESS; (void)test;