Fix "Comparison is always true because ret >= 0" LGTM warnings

... and refactor out some other dead code in the vacinity of these warnings
master
Douglas Anderson 4 years ago committed by Xavier Arteaga
parent f5ca40e3bf
commit fe21b2717c

@ -265,7 +265,7 @@ int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t* q,
float max_peak_value = -1.0; float max_peak_value = -1.0;
uint32_t nof_detected_cells = 0; uint32_t nof_detected_cells = 0;
for (uint32_t N_id_2 = 0; N_id_2 < 3 && ret >= 0; N_id_2++) { for (uint32_t N_id_2 = 0; N_id_2 < 3; N_id_2++) {
INFO("CELL SEARCH: Starting scan for N_id_2=%d\n", N_id_2); INFO("CELL SEARCH: Starting scan for N_id_2=%d\n", N_id_2);
ret = srslte_ue_cellsearch_scan_N_id_2(q, N_id_2, &found_cells[N_id_2]); ret = srslte_ue_cellsearch_scan_N_id_2(q, N_id_2, &found_cells[N_id_2]);
if (ret < 0) { if (ret < 0) {

@ -245,29 +245,30 @@ int srslte_ue_mib_sync_decode(srslte_ue_mib_sync_t* q,
uint32_t nof_frames = 0; uint32_t nof_frames = 0;
int mib_ret = SRSLTE_UE_MIB_NOTFOUND; int mib_ret = SRSLTE_UE_MIB_NOTFOUND;
if (q != NULL) { if (q == NULL) {
srslte_ue_mib_sync_reset(q); return ret;
}
ret = SRSLTE_SUCCESS; srslte_ue_mib_sync_reset(q);
do {
mib_ret = SRSLTE_UE_MIB_NOTFOUND; do {
ret = srslte_ue_sync_zerocopy(&q->ue_sync, q->sf_buffer, MIB_BUFFER_MAX_SAMPLES); mib_ret = SRSLTE_UE_MIB_NOTFOUND;
if (ret < 0) { ret = srslte_ue_sync_zerocopy(&q->ue_sync, q->sf_buffer, MIB_BUFFER_MAX_SAMPLES);
ERROR("Error calling srslte_ue_sync_work()\n"); if (ret < 0) {
return -1; ERROR("Error calling srslte_ue_sync_work()\n");
} else if (srslte_ue_sync_get_sfidx(&q->ue_sync) == 0) { return -1;
if (ret == 1) { }
mib_ret = srslte_ue_mib_decode(&q->ue_mib, bch_payload, nof_tx_ports, sfn_offset);
} else { if (srslte_ue_sync_get_sfidx(&q->ue_sync) == 0) {
DEBUG("Resetting PBCH decoder after %d frames\n", q->ue_mib.frame_cnt); if (ret == 1) {
srslte_ue_mib_reset(&q->ue_mib); mib_ret = srslte_ue_mib_decode(&q->ue_mib, bch_payload, nof_tx_ports, sfn_offset);
} } else {
nof_frames++; DEBUG("Resetting PBCH decoder after %d frames\n", q->ue_mib.frame_cnt);
srslte_ue_mib_reset(&q->ue_mib);
} }
} while (mib_ret == SRSLTE_UE_MIB_NOTFOUND && ret >= 0 && nof_frames < max_frames_timeout); nof_frames++;
if (mib_ret < 0) {
ret = mib_ret;
} }
} } while (mib_ret == SRSLTE_UE_MIB_NOTFOUND && nof_frames < max_frames_timeout);
return mib_ret; return mib_ret;
} }

@ -244,29 +244,31 @@ int srslte_ue_mib_sync_nbiot_decode(srslte_ue_mib_sync_nbiot_t* q,
uint32_t* nof_tx_ports, uint32_t* nof_tx_ports,
int* sfn_offset) int* sfn_offset)
{ {
int mib_ret = SRSLTE_UE_MIB_NBIOT_NOTFOUND; int ret = SRSLTE_ERROR_INVALID_INPUTS;
uint32_t nof_frames = 0;
int mib_ret = SRSLTE_UE_MIB_NBIOT_NOTFOUND;
if (q != NULL) { if (q == NULL) {
int ret = SRSLTE_SUCCESS; return ret;
uint32_t nof_frames = 0; }
do {
mib_ret = SRSLTE_UE_MIB_NBIOT_NOTFOUND; do {
ret = srslte_ue_sync_nbiot_zerocopy_multi(&q->ue_sync, q->sf_buffer); mib_ret = SRSLTE_UE_MIB_NBIOT_NOTFOUND;
if (ret < 0) { ret = srslte_ue_sync_nbiot_zerocopy_multi(&q->ue_sync, q->sf_buffer);
fprintf(stderr, "Error calling srslte_ue_sync_nbiot_zerocopy_multi()\n"); if (ret < 0) {
break; fprintf(stderr, "Error calling srslte_ue_sync_nbiot_zerocopy_multi()\n");
} else if (srslte_ue_sync_nbiot_get_sfidx(&q->ue_sync) == 0) { break;
mib_ret = srslte_ue_mib_nbiot_decode(&q->ue_mib, NULL, bch_payload, nof_tx_ports, sfn_offset); }
if (mib_ret < 0) {
DEBUG("Resetting NPBCH decoder after %d frames\n", q->ue_mib.frame_cnt); if (srslte_ue_sync_nbiot_get_sfidx(&q->ue_sync) == 0) {
srslte_ue_mib_nbiot_reset(&q->ue_mib); mib_ret = srslte_ue_mib_nbiot_decode(&q->ue_mib, NULL, bch_payload, nof_tx_ports, sfn_offset);
} if (mib_ret < 0) {
nof_frames++; DEBUG("Resetting NPBCH decoder after %d frames\n", q->ue_mib.frame_cnt);
srslte_ue_mib_nbiot_reset(&q->ue_mib);
} }
} while (mib_ret == SRSLTE_UE_MIB_NBIOT_NOTFOUND && ret >= 0 && nof_frames < max_frames_timeout); nof_frames++;
if (mib_ret < 0) {
ret = mib_ret;
} }
} } while (mib_ret == SRSLTE_UE_MIB_NBIOT_NOTFOUND && nof_frames < max_frames_timeout);
return mib_ret; return mib_ret;
} }

Loading…
Cancel
Save