[PATCH 2/3] staging: rtl8723bs: remove unnecessary pointer-to-integer casts

From: Ashmit Kumar

Date: Sun Oct 18 2026 - 12:46:01 EST


The pointer pframe in rtw_mlme_ext.c is cast to (SIZE_PTR) before
being passed as an argument or evaluated in expressions where it is
already a pointer type. In xmit_linux.c, the buffer length was
calculated using unnecessary casts:
(SIZE_PTR)pfile->cur_addr - (SIZE_PTR)pfile->buf_start
where standard pointer subtraction pfile->cur_addr - pfile->buf_start
yields ptrdiff_t directly without any casting.

Remove these redundant casts to simplify the code and use standard C
pointer arithmetic.

Signed-off-by: Ashmit Kumar <work.ashmitkumar@xxxxxxxxx>
---
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 ++++----
drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 511eccf5b5a3..9e89d4a0392d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -707,8 +707,8 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
offset = 4;
}

- algorithm = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset));
- seq = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 2));
+ algorithm = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + offset));
+ seq = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + offset + 2));

if (auth_mode == 2 &&
psecuritypriv->dot11_privacy_algrthm != _WEP40_ &&
@@ -856,8 +856,8 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram

offset = (GetPrivacy(pframe)) ? 4 : 0;

- seq = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 2));
- status = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 4));
+ seq = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + offset + 2));
+ status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + offset + 4));

if (status != 0) {
if (status == 13) { /* pmlmeinfo->auth_algo == dot11_auth_algrthm_auto) */
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 6ee2a1f29aa4..91ab0f8bcb69 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -9,7 +9,7 @@

unsigned int rtw_remainder_len(struct pkt_file *pfile)
{
- return (pfile->buf_len - ((SIZE_PTR)(pfile->cur_addr) - (SIZE_PTR)(pfile->buf_start)));
+ return pfile->buf_len - (pfile->cur_addr - pfile->buf_start);
}

void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile)
--
2.43.0