staging: r8188eu: replace ternary operator with min, max, abs macros
authorMichael Straube <straube.linux@gmail.com>
Mon, 31 Oct 2022 15:37:43 +0000 (16:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Nov 2022 07:17:22 +0000 (08:17 +0100)
Replace some ternary operators with the min(), max() or abs() macros
to improve readability.

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20221031153743.8801-1-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_xmit.c
drivers/staging/r8188eu/hal/HalPhyRf_8188e.c
drivers/staging/r8188eu/hal/odm_RTL8188E.c

index 4f82204283282b90478617d14faf4709dfc77ecd..bd6c1a401c590714b6b6d1f73de49d8c083cb35e 100644 (file)
@@ -476,8 +476,7 @@ static uint rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
 {
        uint len;
 
-       len = rtw_remainder_len(pfile);
-       len = (rlen > len) ? len : rlen;
+       len = min(rtw_remainder_len(pfile), rlen);
 
        if (rmem)
                skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len);
index 60cdfcf80daadfd6793979000775b915008479a1..622f95d3f2edf1f11f3f9f06b0b99f3308df6529 100644 (file)
@@ -583,7 +583,7 @@ static bool phy_SimularityCompare_8188E(
                        tmp2 = resulta[c2][i];
                }
 
-               diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1);
+               diff = abs(tmp1 - tmp2);
 
                if (diff > MAX_TOLERANCE) {
                        if ((i == 2 || i == 6) && !sim_bitmap) {
index dd9c8291f025dc5c2b9d00cffc1c2a769f4718ab..f3f4074d4316763d7d432a9a61ab1bfa1cd4e915 100644 (file)
@@ -199,7 +199,7 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm)
                        Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i] / dm_fat_tbl->AuxAnt_Cnt[i]) : 0;
                        TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT;
                        /* 2 Select MaxRSSI for DIG */
-                       LocalMaxRSSI = (Main_RSSI > Aux_RSSI) ? Main_RSSI : Aux_RSSI;
+                       LocalMaxRSSI = max(Main_RSSI, Aux_RSSI);
                        if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40))
                                AntDivMaxRSSI = LocalMaxRSSI;
                        if (LocalMaxRSSI > MaxRSSI)
@@ -211,7 +211,7 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm)
                        else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0))
                                Aux_RSSI = Main_RSSI;
 
-                       LocalMinRSSI = (Main_RSSI > Aux_RSSI) ? Aux_RSSI : Main_RSSI;
+                       LocalMinRSSI = min(Main_RSSI, Aux_RSSI);
                        if (LocalMinRSSI < MinRSSI) {
                                MinRSSI = LocalMinRSSI;
                                RxIdleAnt = TargetAnt;