Skip to content

Commit b6554ea

Browse files
committed
[media] drxj: don't do math if not needed
While there's no risk of divison by zero, the logic there is akward, as it does the calculus for the numerator and denominator before checking if this will be used. Change the order to check first if the denominator is zero, and only calculating the numerator/denominator if not. This should also avoid those smatch errors: drivers/media/dvb-frontends/drx39xyj/drxj.c:9605 ctrl_get_qam_sig_quality() debug: sval_binop_unsigned: divide by zero drivers/media/dvb-frontends/drx39xyj/drxj.c:9605 ctrl_get_qam_sig_quality() debug: sval_binop_unsigned: divide by zero drivers/media/dvb-frontends/drx39xyj/drxj.c:9605 ctrl_get_qam_sig_quality() debug: sval_binop_unsigned: divide by zero drivers/media/dvb-frontends/drx39xyj/drxj.c:9605 ctrl_get_qam_sig_quality() debug: sval_binop_unsigned: divide by zero drivers/media/dvb-frontends/drx39xyj/drxj.c:9605 ctrl_get_qam_sig_quality() debug: sval_binop_unsigned: divide by zero Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent f6f7b58 commit b6554ea

File tree

1 file changed

+5
-4
lines changed
  • drivers/media/dvb-frontends/drx39xyj

1 file changed

+5
-4
lines changed

drivers/media/dvb-frontends/drx39xyj/drxj.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9597,12 +9597,13 @@ ctrl_get_qam_sig_quality(struct drx_demod_instance *demod)
95979597
95989598
Precision errors still possible.
95999599
*/
9600-
e = post_bit_err_rs * 742686;
9601-
m = fec_oc_period * 100;
9602-
if (fec_oc_period == 0)
9600+
if (!fec_oc_period) {
96039601
qam_post_rs_ber = 0xFFFFFFFF;
9604-
else
9602+
} else {
9603+
e = post_bit_err_rs * 742686;
9604+
m = fec_oc_period * 100;
96059605
qam_post_rs_ber = e / m;
9606+
}
96069607

96079608
/* fill signal quality data structure */
96089609
p->pre_bit_count.stat[0].scale = FE_SCALE_COUNTER;

0 commit comments

Comments
 (0)