diff options
author | Dan Gopstein <dgopstein@nyu.edu> | 2017-12-25 16:16:14 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2018-03-06 04:08:17 -0500 |
commit | 7aa92c4229fefff0cab6930cf977f4a0e3e606d8 (patch) | |
tree | 31f5e43b03e4837db5eff1dc04ed477d2bfdaf43 /drivers/media/dvb-frontends/dib0090.c | |
parent | 62474660fb2d92bb3f419769912517cccac2cf96 (diff) |
media: ABS macro parameter parenthesization
Replace usages of the locally defined ABS() macro with calls to the
canonical abs() from kernel.h and remove the old definitions of ABS()
This change was originally motivated by two local definitions of the
ABS (absolute value) macro that fail to parenthesize their parameter
properly. This can lead to a bad expansion for low-precedence
expression arguments.
For example: ABS(1-2) currently expands to ((1-2) < 0 ? (-1-2) : (1-2))
which evaluates to -3. But the correct expansion would be
((1-2) < 0 ? -(1-2) : (1-2)) which evaluates to 1.
Signed-off-by: Dan Gopstein <dgopstein@nyu.edu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-frontends/dib0090.c')
-rw-r--r-- | drivers/media/dvb-frontends/dib0090.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/dvb-frontends/dib0090.c b/drivers/media/dvb-frontends/dib0090.c index 64f49c8eb1fb..ee7af34979ed 100644 --- a/drivers/media/dvb-frontends/dib0090.c +++ b/drivers/media/dvb-frontends/dib0090.c @@ -1285,7 +1285,7 @@ int dib0090_gain_control(struct dvb_frontend *fe) #endif if (*tune_state == CT_AGC_STEP_1) { /* quickly go to the correct range of the ADC power */ - if (ABS(adc_error) < 50 || state->agc_step++ > 5) { + if (abs(adc_error) < 50 || state->agc_step++ > 5) { #ifdef CONFIG_STANDARD_DAB if (state->fe->dtv_property_cache.delivery_system == STANDARD_DAB) { @@ -1754,7 +1754,7 @@ static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum front *tune_state = CT_TUNER_STEP_1; } else { /* the minimum was what we have seen in the step before */ - if (ABS(state->adc_diff) > ABS(state->min_adc_diff)) { + if (abs(state->adc_diff) > abs(state->min_adc_diff)) { dprintk("Since adc_diff N = %d > adc_diff step N-1 = %d, Come back one step\n", state->adc_diff, state->min_adc_diff); state->step--; } |