fix potential error where return value -1 is used for loop termination

This commit is contained in:
Andre Puschmann 2020-05-06 14:29:31 +02:00
parent 340ec61e8e
commit 7aeddfd186
2 changed files with 14 additions and 9 deletions

View File

@ -163,7 +163,7 @@ SRSLTE_API bool srslte_slss_side_peak_value_is_valid(float side_peak_value, floa
SRSLTE_API int srslte_sl_tm_to_cell_sl_tm_t(srslte_cell_sl_t* q, uint32_t tm); SRSLTE_API int srslte_sl_tm_to_cell_sl_tm_t(srslte_cell_sl_t* q, uint32_t tm);
SRSLTE_API int srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp); SRSLTE_API uint32_t srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp);
SRSLTE_API bool srslte_psbch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp); SRSLTE_API bool srslte_psbch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp);
SRSLTE_API bool srslte_pscch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp); SRSLTE_API bool srslte_pscch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp);
SRSLTE_API bool srslte_pssch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp); SRSLTE_API bool srslte_pssch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp);

View File

@ -90,7 +90,13 @@ int srslte_sl_tm_to_cell_sl_tm_t(srslte_cell_sl_t* q, uint32_t tm)
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
int srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp) /* Returns the number of OFDM symbols depending on the Sidelink transmission mode and the CP
*
* @param tm Sidelink transmission mode
* @cp Cyclic prefix
* @return Number of symbols (0 if invalid params where given)
*/
uint32_t srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp)
{ {
if (tm == SRSLTE_SIDELINK_TM1 || tm == SRSLTE_SIDELINK_TM2) { if (tm == SRSLTE_SIDELINK_TM1 || tm == SRSLTE_SIDELINK_TM2) {
if (cp == SRSLTE_CP_NORM) { if (cp == SRSLTE_CP_NORM) {
@ -102,13 +108,12 @@ int srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp)
if (cp == SRSLTE_CP_NORM) { if (cp == SRSLTE_CP_NORM) {
return SRSLTE_CP_NORM_SF_NSYMB; return SRSLTE_CP_NORM_SF_NSYMB;
} else { } else {
printf("Invalid CP\n"); ERROR("Invalid CP\n");
return SRSLTE_ERROR;
} }
} else { } else {
printf("Invalid TM\n"); ERROR("Invalid TM\n");
return SRSLTE_ERROR;
} }
return 0; // Calling function may use return value for loop termination
} }
// Look-up tables for Sidelink channel symbols // Look-up tables for Sidelink channel symbols