提交 ba6457bb authored 作者: Steve Underwood's avatar Steve Underwood

Some more coverity issues cleaned up

上级 dac846cc
...@@ -78,7 +78,7 @@ static __inline__ int32_t pow_ii(int32_t x, int32_t n) ...@@ -78,7 +78,7 @@ static __inline__ int32_t pow_ii(int32_t x, int32_t n)
if (n == 0 || x == 1) if (n == 0 || x == 1)
return 1; return 1;
if (x != -1) if (x != -1)
return (x == 0) ? 1/x : 0; return (x != 0) ? 1/x : 0;
n = -n; n = -n;
} }
u = n; u = n;
......
...@@ -1252,6 +1252,7 @@ SPAN_DECLARE_NONSTD(int) v17_rx(v17_rx_state_t *s, const int16_t amp[], int len) ...@@ -1252,6 +1252,7 @@ SPAN_DECLARE_NONSTD(int) v17_rx(v17_rx_state_t *s, const int16_t amp[], int len)
complexf_t sample; complexf_t sample;
float v; float v;
#endif #endif
int32_t root_power;
int32_t power; int32_t power;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
...@@ -1309,11 +1310,15 @@ SPAN_DECLARE_NONSTD(int) v17_rx(v17_rx_state_t *s, const int16_t amp[], int len) ...@@ -1309,11 +1310,15 @@ SPAN_DECLARE_NONSTD(int) v17_rx(v17_rx_state_t *s, const int16_t amp[], int len)
{ {
/* Only AGC until we have locked down the setting. */ /* Only AGC until we have locked down the setting. */
if (s->agc_scaling_save == FP_SCALE(0.0f)) if (s->agc_scaling_save == FP_SCALE(0.0f))
{
if ((root_power = fixed_sqrt32(power)) == 0)
root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINTx) #if defined(SPANDSP_USE_FIXED_POINTx)
s->agc_scaling = saturate16(((int32_t) (FP_SCALE(2.17f)*1024.0f))/fixed_sqrt32(power)); s->agc_scaling = saturate16(((int32_t) (FP_SCALE(2.17f)*1024.0f))/root_power);
#else #else
s->agc_scaling = (FP_SCALE(2.17f)/RX_PULSESHAPER_GAIN)/sqrtf(power); s->agc_scaling = (FP_SCALE(2.17f)/RX_PULSESHAPER_GAIN)/root_power;
#endif #endif
}
/* Pulse shape while still at the carrier frequency, using a quadrature /* Pulse shape while still at the carrier frequency, using a quadrature
pair of filters. This results in a properly bandpass filtered complex pair of filters. This results in a properly bandpass filtered complex
signal, which can be brought directly to baseband by complex mixing. signal, which can be brought directly to baseband by complex mixing.
......
...@@ -799,6 +799,7 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l ...@@ -799,6 +799,7 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l
float ii; float ii;
float qq; float qq;
#endif #endif
int32_t root_power;
int32_t power; int32_t power;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
...@@ -860,10 +861,12 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l ...@@ -860,10 +861,12 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l
if (s->rx.training == V22BIS_RX_TRAINING_STAGE_SYMBOL_ACQUISITION) if (s->rx.training == V22BIS_RX_TRAINING_STAGE_SYMBOL_ACQUISITION)
{ {
/* Only AGC during the initial symbol acquisition, and then lock the gain. */ /* Only AGC during the initial symbol acquisition, and then lock the gain. */
if ((root_power = fixed_sqrt32(power)) == 0)
root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
s->rx.agc_scaling = saturate16(((int32_t) (FP_SCALE(0.18f)*FP_SCALE(3.60f)))/fixed_sqrt32(power)); s->rx.agc_scaling = saturate16(((int32_t) (FP_SCALE(0.18f)*FP_SCALE(3.60f)))/root_power);
#else #else
s->rx.agc_scaling = FP_SCALE(0.18f)*FP_SCALE(3.60f)/fixed_sqrt32(power); s->rx.agc_scaling = FP_SCALE(0.18f)*FP_SCALE(3.60f)/root_power;
#endif #endif
} }
/* Pulse shape while still at the carrier frequency, using a quadrature /* Pulse shape while still at the carrier frequency, using a quadrature
......
...@@ -834,6 +834,7 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in ...@@ -834,6 +834,7 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in
complexf_t sample; complexf_t sample;
float v; float v;
#endif #endif
int32_t root_power;
int32_t power; int32_t power;
if (s->bit_rate == 4800) if (s->bit_rate == 4800)
...@@ -858,10 +859,12 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in ...@@ -858,10 +859,12 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in
if (s->training_stage == TRAINING_STAGE_SYMBOL_ACQUISITION) if (s->training_stage == TRAINING_STAGE_SYMBOL_ACQUISITION)
{ {
/* Only AGC during the initial training */ /* Only AGC during the initial training */
if ((root_power = fixed_sqrt32(power)) == 0)
root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.414f)*1024.0f))/fixed_sqrt32(power)); s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.414f)*1024.0f))/root_power);
#else #else
s->agc_scaling = (FP_SCALE(1.414f)/RX_PULSESHAPER_4800_GAIN)/fixed_sqrt32(power); s->agc_scaling = (FP_SCALE(1.414f)/RX_PULSESHAPER_4800_GAIN)/root_power;
#endif #endif
} }
/* Pulse shape while still at the carrier frequency, using a quadrature /* Pulse shape while still at the carrier frequency, using a quadrature
...@@ -920,10 +923,12 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in ...@@ -920,10 +923,12 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in
if (s->training_stage == TRAINING_STAGE_SYMBOL_ACQUISITION) if (s->training_stage == TRAINING_STAGE_SYMBOL_ACQUISITION)
{ {
/* Only AGC during the initial training */ /* Only AGC during the initial training */
if ((root_power = fixed_sqrt32(power)) == 0)
root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.414f)*1024.0f))/fixed_sqrt32(power)); s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.414f)*1024.0f))/root_power);
#else #else
s->agc_scaling = (FP_SCALE(1.414f)/RX_PULSESHAPER_2400_GAIN)/fixed_sqrt32(power); s->agc_scaling = (FP_SCALE(1.414f)/RX_PULSESHAPER_2400_GAIN)/root_power;
#endif #endif
} }
/* Pulse shape while still at the carrier frequency, using a quadrature /* Pulse shape while still at the carrier frequency, using a quadrature
......
...@@ -908,6 +908,7 @@ SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) ...@@ -908,6 +908,7 @@ SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len)
complexf_t sample; complexf_t sample;
float v; float v;
#endif #endif
int32_t root_power;
int32_t power; int32_t power;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
...@@ -970,10 +971,12 @@ SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) ...@@ -970,10 +971,12 @@ SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len)
/* Only AGC until we have locked down the setting. */ /* Only AGC until we have locked down the setting. */
if (s->agc_scaling_save == FP_SCALE(0.0f)) if (s->agc_scaling_save == FP_SCALE(0.0f))
{ {
if ((root_power = fixed_sqrt32(power)) == 0)
root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.25f)*1024.0f))/fixed_sqrt32(power)); s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.25f)*1024.0f))/root_power);
#else #else
s->agc_scaling = (FP_SCALE(1.25f)/RX_PULSESHAPER_GAIN)/fixed_sqrt32(power); s->agc_scaling = (FP_SCALE(1.25f)/RX_PULSESHAPER_GAIN)/root_power;
#endif #endif
} }
/* Pulse shape while still at the carrier frequency, using a quadrature /* Pulse shape while still at the carrier frequency, using a quadrature
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论