From: Nam Cao <namcaov@gmail.com>
To: gregkh@linuxfoundation.org
Cc: phil@philpotter.co.uk, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org, Nam Cao <namcaov@gmail.com>
Subject: [PATCH 2/2] staging: r8188eu: replace FIELD_OFFSET with offsetof
Date: Sun, 12 Jun 2022 03:05:14 +0200 [thread overview]
Message-ID: <9443ef83f565eafe1e4f348412772d4ab966093a.1654994517.git.namcaov@gmail.com> (raw)
In-Reply-To: <cover.1654994517.git.namcaov@gmail.com>
This driver defines FIELD_OFFSET which does the same as offsetof.
Replace this macro with offsetof.
Signed-off-by: Nam Cao <namcaov@gmail.com>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 4 ++--
drivers/staging/r8188eu/include/basic_types.h | 2 --
drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 ++--
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 87bf37f33606..2be166abe99c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -7072,7 +7072,7 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf)
/* clear CAM */
flush_all_cam_entry(padapter);
- memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength));
+ memcpy(pnetwork, pbuf, offsetof(struct wlan_bssid_ex, IELength));
pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength;
if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */
@@ -7129,7 +7129,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf)
pmlmeinfo->candidate_tid_bitmap = 0;
pmlmeinfo->bwmode_updated = false;
- memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength));
+ memcpy(pnetwork, pbuf, offsetof(struct wlan_bssid_ex, IELength));
pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength;
if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */
diff --git a/drivers/staging/r8188eu/include/basic_types.h b/drivers/staging/r8188eu/include/basic_types.h
index c4b08fb82200..0b71e2c6e41a 100644
--- a/drivers/staging/r8188eu/include/basic_types.h
+++ b/drivers/staging/r8188eu/include/basic_types.h
@@ -9,8 +9,6 @@
typedef void (*proc_t)(void *);
-#define FIELD_OFFSET(s, field) ((ssize_t)&((s *)(0))->field)
-
/* port from fw */
/* TODO: Macros Below are Sync from SD7-Driver. It is necessary
* to check correctness */
diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index 1b09462ca908..2063ace8398f 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -403,7 +403,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
if (wep_key_len > 0) {
wep_key_len = wep_key_len <= 5 ? 5 : 13;
- wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
+ wep_total_len = wep_key_len + offsetof(struct ndis_802_11_wep, KeyMaterial);
pwep = kzalloc(wep_total_len, GFP_KERNEL);
if (!pwep)
goto exit;
@@ -1593,7 +1593,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
if (erq->length > 0) {
wep.KeyLength = erq->length <= 5 ? 5 : 13;
- wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
+ wep.Length = wep.KeyLength + offsetof(struct ndis_802_11_wep, KeyMaterial);
} else {
wep.KeyLength = 0;
--
2.25.1
prev parent reply other threads:[~2022-06-12 1:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-12 1:05 [PATCH 0/2] Clean up some macros Nam Cao
2022-06-12 1:05 ` [PATCH 1/2] staging: r8188eu: simplify " Nam Cao
2022-06-12 4:56 ` Greg KH
2022-06-12 8:11 ` [PATCH v2 0/2] " Nam Cao
2022-06-12 8:11 ` [PATCH v2 1/2] staging: r8188eu: replace LE_BITS_TO_1BYTE with clearer codes Nam Cao
2022-06-13 14:30 ` Dan Carpenter
2022-06-14 9:34 ` Greg KH
2022-06-14 15:58 ` [PATCH v3 0/2] get rid of confusing macros Nam Cao
2022-06-14 15:58 ` [PATCH v3 1/2] staging: r8188eu: replace " Nam Cao
2022-06-14 15:58 ` [PATCH v3 2/2] staging: r8188eu: remove unused macros Nam Cao
2022-06-15 8:29 ` [PATCH v3 0/2] get rid of confusing macros Dan Carpenter
2022-06-12 8:11 ` [PATCH v2 2/2] staging: r8188eu: remove unused macros Nam Cao
2022-06-12 1:05 ` Nam Cao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9443ef83f565eafe1e4f348412772d4ab966093a.1654994517.git.namcaov@gmail.com \
--to=namcaov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=phil@philpotter.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®