Skip to contentSkip to conversation

Replace data type declarations with variables of same types in several source files.

PATCH In review Sergio Paracuellos 2 participants 8 messages Oct 10, 2016 – Oct 16, 2016 Staging

lore
Share & tools
lore
#0 lore raw

cover Replace data type declarations with variables of same types in several source files.

This patch series replaces several sizeof(struct XXX) stuff in favour of sizeof(var) which is the preferred one.

Sergio Paracuellos (5):
staging: wlan-ng: Replace data type declaration with variable of same

    type in cfg80211.c
  staging: wlan-ng: Replace data type declaration with variable of same
    type in hfa384x_usb.c
  staging: wlan-ng: Replace data type declaration with variable of same
    type in p80211conv.c
  staging: wlan-ng: Replace data type declaration with variable of same
    type in p80211netdev.c

staging: wlan-ng: Replace data type declaration with variable of same
type in prism2sta.c

 drivers/staging/wlan-ng/cfg80211.c     |  2 +-
 drivers/staging/wlan-ng/hfa384x_usb.c  |  2 +-
 drivers/staging/wlan-ng/p80211conv.c   |  2 +-
 drivers/staging/wlan-ng/p80211netdev.c | 12 ++++++------
 drivers/staging/wlan-ng/prism2sta.c    |  6 +++---
 5 files changed, 12 insertions(+), 12 deletions(-)
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/5 staging: wlan-ng: Replace data type declaration with variable of same type in hfa384x_usb.c

sizeof(var) instead of sizeof(struct XXX) is preferred. Fix it in hfa384x_usb.c file.

---
 drivers/staging/wlan-ng/hfa384x_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/hfa384x_usb.c +1 -1
index fbd9dc6..a83026e 100644
@@ -531,7 +531,7 @@ static void hfa384x_usb_defer(struct work_struct *data)
  */
 void hfa384x_create(struct hfa384x *hw, struct usb_device *usb)
 {
-	memset(hw, 0, sizeof(struct hfa384x));
+	memset(hw, 0, sizeof(*hw));
 	hw->usb = usb;
 
 	/* set up the endpoints */
Signature · 1 line
1.9.1
#5 lore raw

PATCH 5/5 staging: wlan-ng: Replace data type declaration with variable of same type in prism2sta.c

In reply to Sergio Paracuellos

sizeof(*var) instead of sizeof(struct XXX) is preferred. Fix them in prism2sta.c file.

---
 drivers/staging/wlan-ng/prism2sta.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/wlan-ng/prism2sta.c +3 -4
index b3ae2bb..351f08d 100644
@@ -1102,8 +1102,7 @@ static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
 
 	kfree(hw->scanresults);
 
-	hw->scanresults = kmemdup(inf, sizeof(struct hfa384x_inf_frame),
-				  GFP_ATOMIC);
+	hw->scanresults = kmemdup(inf, sizeof(*inf), GFP_ATOMIC);
 
 	if (nbss == 0)
 		nbss = -1;
@@ -1888,8 +1887,8 @@ static struct wlandevice *create_wlan(void)
 	struct hfa384x *hw = NULL;
 
 	/* Alloc our structures */
-	wlandev = kzalloc(sizeof(struct wlandevice), GFP_KERNEL);
-	hw = kzalloc(sizeof(struct hfa384x), GFP_KERNEL);
+	wlandev = kzalloc(sizeof(*wlandev), GFP_KERNEL);
+	hw = kzalloc(sizeof(*hw), GFP_KERNEL);
 
 	if (!wlandev || !hw) {
 		kfree(wlandev);
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/5 staging: wlan-ng: Replace data type declaration with variable of same type in p80211conv.c

In reply to Sergio Paracuellos

sizeof(*var) instead of sizeof(struct XXX) is preferred. Fix it in p80211conv.c file.

---
 drivers/staging/wlan-ng/p80211conv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/p80211conv.c +1 -1
index 0247cbc..bbed7ff 100644
@@ -615,7 +615,7 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
 	}
 
 	/* Allocate the rxmeta */
-	rxmeta = kzalloc(sizeof(struct p80211_rxmeta), GFP_ATOMIC);
+	rxmeta = kzalloc(sizeof(*rxmeta), GFP_ATOMIC);
 
 	if (!rxmeta) {
 		netdev_err(wlandev->netdev,
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/5 staging: wlan-ng: Replace data type declaration with variable of same type in cfg80211.c

In reply to Sergio Paracuellos

sizeof(var) instead of sizeof(struct XXX) is preferred. Fix it in cfg80211.c file.

---
 drivers/staging/wlan-ng/cfg80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/cfg80211.c +1 -1
index 182b2d5..67c48a8 100644
@@ -323,7 +323,7 @@ static int prism2_scan(struct wiphy *wiphy,
 
 	priv->scan_request = request;
 
-	memset(&msg1, 0x00, sizeof(struct p80211msg_dot11req_scan));
+	memset(&msg1, 0x00, sizeof(msg1));
 	msg1.msgcode = DIDmsg_dot11req_scan;
 	msg1.bsstype.data = P80211ENUM_bsstype_any;
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/5 staging: wlan-ng: Replace data type declaration with variable of same type in p80211netdev.c

In reply to Sergio Paracuellos

sizeof(var) instead of sizeof(struct XXX) is preferred. Fix them in p80211netdev.c

---
 drivers/staging/wlan-ng/p80211netdev.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/wlan-ng/p80211netdev.c +6 -6
index 825a63a..3a95b36 100644
@@ -336,8 +336,8 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
 		goto failed;
 	}
 
-	memset(&p80211_hdr, 0, sizeof(union p80211_hdr));
-	memset(&p80211_wep, 0, sizeof(struct p80211_metawep));
+	memset(&p80211_hdr, 0, sizeof(p80211_hdr));
+	memset(&p80211_wep, 0, sizeof(p80211_wep));
 
 	if (netif_queue_stopped(netdev)) {
 		netdev_dbg(netdev, "called when queue stopped.\n");
@@ -375,8 +375,8 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
 			goto failed;
 		}
 		/* move the header over */
-		memcpy(&p80211_hdr, skb->data, sizeof(union p80211_hdr));
-		skb_pull(skb, sizeof(union p80211_hdr));
+		memcpy(&p80211_hdr, skb->data, sizeof(p80211_hdr));
+		skb_pull(skb, sizeof(p80211_hdr));
 	} else {
 		if (skb_ether_to_p80211
 		    (wlandev, wlandev->ethconv, skb, &p80211_hdr,
@@ -629,9 +629,9 @@ static int p80211knetdev_set_mac_address(struct net_device *dev, void *addr)
 	resultcode = &dot11req.resultcode;
 
 	/* Set up a dot11req_mibset */
-	memset(&dot11req, 0, sizeof(struct p80211msg_dot11req_mibset));
+	memset(&dot11req, 0, sizeof(dot11req));
 	dot11req.msgcode = DIDmsg_dot11req_mibset;
-	dot11req.msglen = sizeof(struct p80211msg_dot11req_mibset);
+	dot11req.msglen = sizeof(dot11req);
 	memcpy(dot11req.devname,
 	       ((struct wlandevice *)dev->ml_priv)->name, WLAN_DEVNAMELEN_MAX - 1);
 
Signature · 1 line
1.9.1
#6 lore raw
In reply to Sergio Paracuellos
Quoted 3 lines · Sergio Paracuellos

This patch series replaces several sizeof(struct XXX) stuff in favour of sizeof(var) which is the preferred one.

Why not squash this series into one patch? The commit messages are fairly similar and the changes are focused into one area. Would be better with one commit, IMO.

Signature · 3 lines
Mit freundlichen Grüßen

Alexander Alemayhu
#7 lore raw
Quoted 9 lines · Alexander Alemayhu
Quoted 3 lines · Sergio Paracuellos

This patch series replaces several sizeof(struct XXX) stuff in favour of sizeof(var) which is the preferred one.

Why not squash this series into one patch? The commit messages are fairly similar and the changes are focused into one area. Would be better with one commit, IMO.

Commit messages are similar but applies to different files. That was the reason of sending the patchset and not only one patch. If it had been better to send only one patch please, let me know to be correct next time. The patchset seems that has been already added to the staging branch.

Thanks in advance.

Cheers,
Sergio Paracuellos