Staging: Replace ternary operators with macros min/max
v2 cover Staging: Replace ternary operators with macros min/max
This patchset replaces ternary operators with macros min/max as they are shorter and thus increases code readability. Macro min returns the minimum and macro max returns maximum of the two compared values. Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
Changes in v2:
* Use min()/max() instead of min_t()/max_t() as the values passed in the macros are of same type.
Bhumika Goyal (5):
Staging: rtl8723au: Use min macro instead of ternary operator
Staging: rdma: Use min macro instead of ternary operator
Staging: gdm724x: Use min instead of ternary operator
Staging: lustre: Use min or max instead of ternary operator
Staging: rts5208: Use min instead of ternary operator
drivers/staging/gdm724x/gdm_mux.c | 2 +- drivers/staging/lustre/lustre/include/lustre_disk.h | 6 ++---- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- drivers/staging/rdma/hfi1/pio_copy.c | 6 +++--- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 14 +++++++------- drivers/staging/rts5208/sd.c | 4 ++-- 7 files changed, 17 insertions(+), 19 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/5 Staging: rtl8723au: Use min macro instead of ternary operator
This patch replaces ternary operator with macro min as it shorter and thus increases code readability. Macro min return the minimum of the two compared values.
Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min() instead of min_t() as the values passed in the macro are of same type.
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +7 -7
@@ -542,7 +542,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,memcpy (psecuritypriv-> dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len)));/* set mic key */ memcpy(psecuritypriv->
@@ -564,7 +564,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,memcpy (psecuritypriv-> dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len))); }else {DBG_8723A ("%s, set group_key, none\n" , __func__);
@@ -602,7 +602,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,if (set_tx ==1 ) {/* pairwise key */ memcpy (psta->dot118021x_UncstKey.skey, - keyparms->key, (key_len >16 ?16 : key_len)); + keyparms->key, (min (16 , key_len)));if (keyparms->cipher ==WLAN_CIPHER_SUITE_WEP40 || keyparms->cipher ==WLAN_CIPHER_SUITE_WEP104 ) {
@@ -660,7 +660,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,memcpy (psecuritypriv-> dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len)));/* set mic key */ memcpy(psecuritypriv->
@@ -678,7 +678,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,memcpy (psecuritypriv-> dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len))); }else { psecuritypriv->dot118021XGrpPrivacy =0 ; }
@@ -788,7 +788,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, u8 key_index,memcpy (psta->dot118021x_UncstKey.skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len)));if (keyparms->cipher ==WLAN_CIPHER_SUITE_TKIP ) {
@@ -811,7 +811,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, u8 key_index,memcpy (padapter->securitypriv. dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len)));memcpy (padapter->securitypriv. dot118021XGrptxmickey[key_index]. skey, &keyparms->key[16 ],8 );
Signature · 1 line
1.9.1
PATCH v2 2/5 Staging: rdma: Use min macro instead of ternary operator
In reply to Bhumika GoyalThis patch replaces ternary operator with macro min as it shorter and thus increases code readability. Macro min return the minimum of the two compared values.
Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min() instead of min_t() as the values passed in the macro are of same type.
drivers/staging/rdma/hfi1/pio_copy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rdma/hfi1/pio_copy.c +3 -3
@@ -235,7 +235,7 @@ static inline void read_extra_bytes(struct pio_buf *pbuf,while (nbytes) {/* find the number of bytes in this u64 */ room =8 - off;/* this u64 has room for this many bytes */ - xbytes = nbytes > room ? room : nbytes; + xbytes =min (room, nbytes);/* * shift down to zero lower bytes, shift up to zero upper
@@ -565,7 +565,7 @@ static void mid_copy_mix(struct pio_buf *pbuf, const void *from, size_t nbytes)/* calculate the end of data or end of block, whichever comes first */ send = pbuf->start +PIO_BLOCK_SIZE ; - xend = send < dend ? send : dend; + xend =min (send, dend);/* shift up to SOP=1 space */ dest +=SOP_DISTANCE ;
@@ -659,7 +659,7 @@ static void mid_copy_straight(struct pio_buf *pbuf,/* calculate the end of data or end of block, whichever comes first */ send = pbuf->start +PIO_BLOCK_SIZE ; - xend = send < dend ? send : dend; + xend =min (send, dend);/* shift up to SOP=1 space */ dest +=SOP_DISTANCE ;
Signature · 1 line
1.9.1
PATCH v2 3/5 Staging: gdm724x: Use min instead of ternary operator
In reply to Bhumika GoyalThis patch replaces ternary operator with macro min as it shorter and thus increases code readability. Macro min return the minimum of the two compared values.
Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min() instead of min_t() as the values passed in the macro are of same type.
drivers/staging/gdm724x/gdm_mux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gdm724x/gdm_mux.c +1 -1
@@ -433,7 +433,7 @@ static int gdm_mux_send_control(void *priv_dev, int request, int value,if (ret <0 )pr_err ("usb_control_msg error: %d\n" , ret); -return ret <0 ? ret :0 ; +return min (ret,0 ); }static void release_usb (struct mux_dev *mux_dev)
Signature · 1 line
1.9.1
PATCH v2 4/5 Staging: lustre: Use min or max instead of ternary operator
In reply to Bhumika GoyalReplace ternary operators with macros min/max as they are shorter and thus increases code readability. Macro min returns the minimum and max returns maximum of the two compared values. Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min()/max() instead of min_t()/max_t() as the values passed in the macros are of same type.
drivers/staging/lustre/lustre/include/lustre_disk.h | 6 ++---- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/include/lustre_disk.h +2 -4
@@ -331,14 +331,12 @@ static inline void lcd_cpu_to_le(struct lsd_client_data *lcd,static inline __u64 lcd_last_transno (struct lsd_client_data *lcd) { -return (lcd->lcd_last_transno > lcd->lcd_last_close_transno ? - lcd->lcd_last_transno : lcd->lcd_last_close_transno); +return max (lcd->lcd_last_transno, lcd->lcd_last_close_transno); }static inline __u64 lcd_last_xid (struct lsd_client_data *lcd) { -return (lcd->lcd_last_xid > lcd->lcd_last_close_xid ? - lcd->lcd_last_xid : lcd->lcd_last_close_xid); +return max (lcd->lcd_last_xid, lcd->lcd_last_close_xid); }/****************** superblock additional info *********************/
drivers/staging/lustre/lustre/osc/osc_request.c +1 -1
@@ -1170,7 +1170,7 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count, }while (nob >0 && pg_count >0 ) { -int count = pga[i]->count > nob ? nob : pga[i]->count; +int count =min (nob, pga[i]->count);/* corrupt the data before we compute the checksum, to * simulate an OST->client data error */
drivers/staging/lustre/lustre/ptlrpc/events.c +1 -1
@@ -254,7 +254,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, new_seq = (sec <<REQS_SEC_SHIFT ) | (usec <<REQS_USEC_SHIFT ) | - (svcpt->scp_cpt <0 ?0 : svcpt->scp_cpt); + (max (0 , svcpt->scp_cpt));if (new_seq > svcpt->scp_hist_seq) {/* This handles the initial case of scp_hist_seq == 0 or
Signature · 1 line
1.9.1
PATCH v2 5/5 Staging: rts5208: Use min instead of ternary operator
In reply to Bhumika GoyalThis patch replaces ternary operator with macro min as it shorter and thus increases code readability. Macro min returns the minimum of the two compared values.
Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min() instead of min_t() as the values passed in the macro are of same type.
drivers/staging/rts5208/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/sd.c +2 -2
@@ -303,7 +303,7 @@ static int sd_read_data(struct rtsx_chip *chip,if (cmd_len) {dev_dbg (rtsx_dev (chip),"SD/MMC CMD %d\n" , cmd[0 ] -0x40 ); -for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++) +for (i =0 ; i < (min (cmd_len,6 )); i++)rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 + i,0xFF , cmd[i]); }
@@ -383,7 +383,7 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode,if (cmd_len) {dev_dbg (rtsx_dev (chip),"SD/MMC CMD %d\n" , cmd[0 ] -0x40 ); -for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++) { +for (i =0 ; i < (min (cmd_len,6 )); i++) {rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 + i,0xFF , cmd[i]); }
Signature · 1 line
1.9.1
Greg KH
maintainerRe: [Outreachy kernel] [PATCH v2 4/5] Staging: lustre: Use min or max instead of ternary operator
In reply to Bhumika GoyalQuoted 68 lines · Bhumika Goyal
Replace ternary operators with macros min/max as they are shorter and thus increases code readability. Macro min returns the minimum and max returns maximum of the two compared values. Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+min(x,y)
|
- x > y ? x : y
+max(x,y)
)Signed-off-by Bhumika Goyal <[email protected]>---
Changes in v2:
Use min()/max() instead of min_t()/max_t() as the values passed in the macros are of same type.drivers/staging/lustre/lustre/include/lustre_disk.h | 6 ++---- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)drivers/staging/lustre/lustre/include/lustre_disk.h +2
-4@@ -331,14 +331,12 @@ static inline void lcd_cpu_to_le(struct lsd_client_data *lcd,static inline __u64 lcd_last_transno (struct lsd_client_data *lcd) { -return (lcd->lcd_last_transno > lcd->lcd_last_close_transno ? - lcd->lcd_last_transno : lcd->lcd_last_close_transno); +return max (lcd->lcd_last_transno, lcd->lcd_last_close_transno); }static inline __u64 lcd_last_xid (struct lsd_client_data *lcd) { -return (lcd->lcd_last_xid > lcd->lcd_last_close_xid ? - lcd->lcd_last_xid : lcd->lcd_last_close_xid); +return max (lcd->lcd_last_xid, lcd->lcd_last_close_xid); }/****************** superblock additional info *********************/ drivers/staging/lustre/lustre/osc/osc_request.c +1
-1@@ -1170,7 +1170,7 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count, }while (nob >0 && pg_count >0 ) { -int count = pga[i]->count > nob ? nob : pga[i]->count; +int count =min (nob, pga[i]->count);/* corrupt the data before we compute the checksum, to * simulate an OST->client data error */ drivers/staging/lustre/lustre/ptlrpc/events.c +0
-0
drivers/staging/lustre/lustre/ptlrpc/events.c static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, · line 260
Quoted 8 lines
drivers/staging/lustre/lustre/ptlrpc/events.c +1
-1@@ -254,7 +254,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, new_seq = (sec <<REQS_SEC_SHIFT ) | (usec <<REQS_USEC_SHIFT ) | - (svcpt->scp_cpt <0 ?0 : svcpt->scp_cpt); + (max (0 , svcpt->scp_cpt));if (new_seq > svcpt->scp_hist_seq) {/* This handles the initial case of scp_hist_seq == 0 or
Doesn't apply due to other changes in this code from other developers. Please rebase and resend.
thanks,
greg k-h
v3 cover Staging: Replace ternary operators with macros min/max
In reply to Bhumika GoyalThis patchset replaces ternary operators with macros min/max as they are shorter and thus increases code readability. Macro min returns the minimum and macro max returns maximum of the two compared values. Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
Changes in v2:
* Use min()/max() instead of min_t()/max_t() as the values passed in the macros are of same type.
Changes in v3:
* No change.
Bhumika Goyal (5):
Staging: rtl8723au: Use min macro instead of ternary operator
Staging: rdma: Use min macro instead of ternary operator
Staging: gdm724x: Use min instead of ternary operator
Staging: lustre: Use min or max instead of ternary operator
Staging: rts5208: Use min instead of ternary operator
drivers/staging/gdm724x/gdm_mux.c | 2 +- drivers/staging/lustre/lustre/include/lustre_disk.h | 6 ++---- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- drivers/staging/rdma/hfi1/pio_copy.c | 6 +++--- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 14 +++++++------- drivers/staging/rts5208/sd.c | 4 ++-- 7 files changed, 17 insertions(+), 19 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 1/5 Staging: rtl8723au: Use min macro instead of ternary operator
This patch replaces ternary operator with macro min as it shorter and thus increases code readability. Macro min return the minimum of the two compared values.
Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min() instead of min_t() as the values passed in the macro are of same type.
Changes in v3:
* No change.
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +7 -7
@@ -542,7 +542,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,memcpy (psecuritypriv-> dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len)));/* set mic key */ memcpy(psecuritypriv->
@@ -564,7 +564,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,memcpy (psecuritypriv-> dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len))); }else {DBG_8723A ("%s, set group_key, none\n" , __func__);
@@ -602,7 +602,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,if (set_tx ==1 ) {/* pairwise key */ memcpy (psta->dot118021x_UncstKey.skey, - keyparms->key, (key_len >16 ?16 : key_len)); + keyparms->key, (min (16 , key_len)));if (keyparms->cipher ==WLAN_CIPHER_SUITE_WEP40 || keyparms->cipher ==WLAN_CIPHER_SUITE_WEP104 ) {
@@ -660,7 +660,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,memcpy (psecuritypriv-> dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len)));/* set mic key */ memcpy(psecuritypriv->
@@ -678,7 +678,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,memcpy (psecuritypriv-> dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len))); }else { psecuritypriv->dot118021XGrpPrivacy =0 ; }
@@ -788,7 +788,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, u8 key_index,memcpy (psta->dot118021x_UncstKey.skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len)));if (keyparms->cipher ==WLAN_CIPHER_SUITE_TKIP ) {
@@ -811,7 +811,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, u8 key_index,memcpy (padapter->securitypriv. dot118021XGrpKey[key_index].skey, keyparms->key, - (key_len >16 ?16 : key_len)); + (min (16 , key_len)));memcpy (padapter->securitypriv. dot118021XGrptxmickey[key_index]. skey, &keyparms->key[16 ],8 );
Signature · 1 line
1.9.1
PATCH v3 2/5 Staging: rdma: Use min macro instead of ternary operator
In reply to Bhumika GoyalThis patch replaces ternary operator with macro min as it shorter and thus increases code readability. Macro min return the minimum of the two compared values.
Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min() instead of min_t() as the values passed in the macro are of same type.
Changes in v3:
* No change.
drivers/staging/rdma/hfi1/pio_copy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rdma/hfi1/pio_copy.c +3 -3
@@ -235,7 +235,7 @@ static inline void read_extra_bytes(struct pio_buf *pbuf,while (nbytes) {/* find the number of bytes in this u64 */ room =8 - off;/* this u64 has room for this many bytes */ - xbytes = nbytes > room ? room : nbytes; + xbytes =min (room, nbytes);/* * shift down to zero lower bytes, shift up to zero upper
@@ -565,7 +565,7 @@ static void mid_copy_mix(struct pio_buf *pbuf, const void *from, size_t nbytes)/* calculate the end of data or end of block, whichever comes first */ send = pbuf->start +PIO_BLOCK_SIZE ; - xend = send < dend ? send : dend; + xend =min (send, dend);/* shift up to SOP=1 space */ dest +=SOP_DISTANCE ;
@@ -659,7 +659,7 @@ static void mid_copy_straight(struct pio_buf *pbuf,/* calculate the end of data or end of block, whichever comes first */ send = pbuf->start +PIO_BLOCK_SIZE ; - xend = send < dend ? send : dend; + xend =min (send, dend);/* shift up to SOP=1 space */ dest +=SOP_DISTANCE ;
Signature · 1 line
1.9.1
PATCH v3 3/5 Staging: gdm724x: Use min instead of ternary operator
In reply to Bhumika GoyalThis patch replaces ternary operator with macro min as it shorter and thus increases code readability. Macro min return the minimum of the two compared values.
Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min() instead of min_t() as the values passed in the macro are of same type.
Changes in v3:
No change
drivers/staging/gdm724x/gdm_mux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gdm724x/gdm_mux.c +1 -1
@@ -433,7 +433,7 @@ static int gdm_mux_send_control(void *priv_dev, int request, int value,if (ret <0 )pr_err ("usb_control_msg error: %d\n" , ret); -return ret <0 ? ret :0 ; +return min (ret,0 ); }static void release_usb (struct mux_dev *mux_dev)
Signature · 1 line
1.9.1
PATCH v3 4/5 Staging: lustre: Use min or max instead of ternary operator
In reply to Bhumika GoyalReplace ternary operators with macros min/max as they are shorter and thus increases code readability. Macro min returns the minimum and max returns maximum of the two compared values. Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min()/max() instead of min_t()/max_t() as the values passed in the macros are of same type.
Changes in v3:
No change
drivers/staging/lustre/lustre/include/lustre_disk.h | 6 ++---- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/include/lustre_disk.h +2 -4
@@ -337,14 +337,12 @@ static inline void lcd_cpu_to_le(struct lsd_client_data *lcd,static inline __u64 lcd_last_transno (struct lsd_client_data *lcd) { -return (lcd->lcd_last_transno > lcd->lcd_last_close_transno ? - lcd->lcd_last_transno : lcd->lcd_last_close_transno); +return (max (lcd->lcd_last_transno, lcd->lcd_last_close_transno)); }static inline __u64 lcd_last_xid (struct lsd_client_data *lcd) { -return (lcd->lcd_last_xid > lcd->lcd_last_close_xid ? - lcd->lcd_last_xid : lcd->lcd_last_close_xid); +return (max (lcd->lcd_last_xid, lcd->lcd_last_close_xid)); } >>>>>>> Staging: lustre: Use min_t and max_t instead of ternary operator
drivers/staging/lustre/lustre/osc/osc_request.c +1 -1
@@ -1181,7 +1181,7 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count, }while (nob >0 && pg_count >0 ) { -int count = pga[i]->count > nob ? nob : pga[i]->count; +int count =min (nob, pga[i]->count);/* corrupt the data before we compute the checksum, to * simulate an OST->client data error
drivers/staging/lustre/lustre/ptlrpc/events.c +1 -1
@@ -260,7 +260,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, new_seq = (sec <<REQS_SEC_SHIFT ) | (usec <<REQS_USEC_SHIFT ) | - (svcpt->scp_cpt <0 ?0 : svcpt->scp_cpt); + (max (0 , svcpt->scp_cpt));if (new_seq > svcpt->scp_hist_seq) {/* This handles the initial case of scp_hist_seq == 0 or
Signature · 1 line
1.9.1
PATCH v3 5/5 Staging: rts5208: Use min instead of ternary operator
In reply to Bhumika GoyalThis patch replaces ternary operator with macro min as it shorter and thus increases code readability. Macro min returns the minimum of the two compared values.
Made a semantic patch for changes:
@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
---
Changes in v2:
Use min() instead of min_t() as the values passed in the macro are of same type.
Changes in v3:
No change
drivers/staging/rts5208/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/sd.c +2 -2
@@ -303,7 +303,7 @@ static int sd_read_data(struct rtsx_chip *chip,if (cmd_len) {dev_dbg (rtsx_dev (chip),"SD/MMC CMD %d\n" , cmd[0 ] -0x40 ); -for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++) +for (i =0 ; i < (min (cmd_len,6 )); i++)rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 + i,0xFF , cmd[i]); }
@@ -383,7 +383,7 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode,if (cmd_len) {dev_dbg (rtsx_dev (chip),"SD/MMC CMD %d\n" , cmd[0 ] -0x40 ); -for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++) { +for (i =0 ; i < (min (cmd_len,6 )); i++) {rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 + i,0xFF , cmd[i]); }
Signature · 1 line
1.9.1