Staging: wilc1000: coreconfigurator: Drop unneeded wrapper functions
PATCH 1/1 Staging: wilc1000: coreconfigurator: Drop unneeded wrapper functions
Remove the wrapper functions get_address1, get_address2 and get_address3 as they are not required and replace their calls by suitable functions. Semantic patch used:
@@
identifier f,g;
@@
*f(...) {
g(...); }
--- drivers/staging/wilc1000/coreconfigurator.c | 48 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-)
drivers/staging/wilc1000/coreconfigurator.c +23 -25
@@ -13,8 +13,12 @@#include "wilc_wlan.h" #include <linux/errno.h> #include <linux/slab.h> +#include <linux/etherdevice.h> #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ BEACON_INTERVAL_LEN + CAP_INFO_LEN) +#define ADDR1 4 +#define ADDR2 10 +#define ADDR3 16/* Basic Frame Type Codes (2-bit) */ enum basic_frame_type {
@@ -171,38 +175,32 @@ static inline u8 get_from_ds(u8 *header)return ((header[1 ] &0x02 ) >>1 ); } -/* This function extracts the MAC Address in 'address1' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address1 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +4 ,6 ); -} - -/* This function extracts the MAC Address in 'address2' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address2 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +10 ,6 ); -} - -/* This function extracts the MAC Address in 'address3' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address3 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +16 ,6 ); -} -/* This function extracts the BSSID from the incoming WLAN packet based on */ -/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */ +/* the 'from ds' bit, and updates the MAC Address in the allocated 'data' */ /* variable. */ static inline void get_BSSID (u8 *data,u8 *bssid) {if (get_from_ds (data) ==1 ) -get_address2 (data, bssid); +/* +* Extract the MAC Address in 'address2' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR2 );else if (get_to_ds (data) ==1 ) -get_address1 (data, bssid); +/* +* Extract the MAC Address in 'address1' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR1 );else -get_address3 (data, bssid); +/* +* Extract the MAC Address in 'address3' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR3 ); }/* This function extracts the SSID from a beacon/probe response frame */
Signature · 1 line
2.1.0
Quoted 2 lines · Shivani Bhardwaj
Remove the wrapper functions
get_address1,get_address2andget_address3as they are not required and replace their calls by suitable functions.
"not required" and "suitable" are not very precise. Something like
Replace the wrapper functions ... by the standard kernel function ...
could be better.
Quoted 8 lines
Semantic patch used:
@@
identifier f,g;
@@*f(...) {
g(...); }
It's not clear what the semantic patch was used for. Actually it was used to find the wrapper functions, but not to do the transformation. This could also be more clear.
It could be good to resend.
julia
Quoted 90 lines
Signed-off-by Shivani Bhardwaj <[email protected]>--- drivers/staging/wilc1000/coreconfigurator.c | 48 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-)drivers/staging/wilc1000/coreconfigurator.c +23
-26@@ -13,8 +13,12 @@#include "wilc_wlan.h" #include <linux/errno.h> #include <linux/slab.h> +#include <linux/etherdevice.h> #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ BEACON_INTERVAL_LEN + CAP_INFO_LEN) +#define ADDR1 4 +#define ADDR2 10 +#define ADDR3 16/* Basic Frame Type Codes (2-bit) */ enum basic_frame_type {@@ -171,38 +175,32 @@ static inline u8 get_from_ds(u8 *header)return ((header[1 ] &0x02 ) >>1 ); } -/* This function extracts the MAC Address in 'address1' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address1 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +4 ,6 ); -} - -/* This function extracts the MAC Address in 'address2' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address2 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +10 ,6 ); -} - -/* This function extracts the MAC Address in 'address3' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address3 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +16 ,6 ); -} -/* This function extracts the BSSID from the incoming WLAN packet based on */ -/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */ +/* the 'from ds' bit, and updates the MAC Address in the allocated 'data' */ /* variable. */ static inline void get_BSSID (u8 *data,u8 *bssid) {if (get_from_ds (data) ==1 ) -get_address2 (data, bssid); +/* +* Extract the MAC Address in 'address2' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR2 );else if (get_to_ds (data) ==1 ) -get_address1 (data, bssid); +/* +* Extract the MAC Address in 'address1' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR1 );else -get_address3 (data, bssid); +/* +* Extract the MAC Address in 'address3' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR3 ); }/* This function extracts the SSID from a beacon/probe response frame */ --2.1.0
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151022125333.GA21176%40ubuntu.
For more options, visit https://groups.google.com/d/optout.
Quoted 20 lines · Julia Lawall
Quoted 2 lines · Shivani Bhardwaj
Remove the wrapper functions
get_address1,get_address2andget_address3as they are not required and replace their calls by suitable functions."not required" and "suitable" are not very precise. Something like
Replace the wrapper functions ... by the standard kernel function ...
could be better.
Quoted 8 lines
Semantic patch used:
@@
identifier f,g;
@@*f(...) {
g(...); }
Quoted 8 lines
It's not clear what the semantic patch was used for. Actually it was used to find the wrapper functions, but not to do the transformation. This could also be more clear.
It could be good to resend.
julia
All right. I'm sending v3.
Thank you.
Quoted 90 lines
Quoted 90 lines
Signed-off-by Shivani Bhardwaj <[email protected]>--- drivers/staging/wilc1000/coreconfigurator.c | 48 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-)drivers/staging/wilc1000/coreconfigurator.c +23
-26@@ -13,8 +13,12 @@#include "wilc_wlan.h" #include <linux/errno.h> #include <linux/slab.h> +#include <linux/etherdevice.h> #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ BEACON_INTERVAL_LEN + CAP_INFO_LEN) +#define ADDR1 4 +#define ADDR2 10 +#define ADDR3 16/* Basic Frame Type Codes (2-bit) */ enum basic_frame_type {@@ -171,38 +175,32 @@ static inline u8 get_from_ds(u8 *header)return ((header[1 ] &0x02 ) >>1 ); } -/* This function extracts the MAC Address in 'address1' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address1 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +4 ,6 ); -} - -/* This function extracts the MAC Address in 'address2' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address2 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +10 ,6 ); -} - -/* This function extracts the MAC Address in 'address3' field of the MAC */ -/* header and updates the MAC Address in the allocated 'addr' variable. */ -static inline void get_address3 (u8 *pu8msa,u8 *addr) -{ -memcpy (addr, pu8msa +16 ,6 ); -} -/* This function extracts the BSSID from the incoming WLAN packet based on */ -/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */ +/* the 'from ds' bit, and updates the MAC Address in the allocated 'data' */ /* variable. */ static inline void get_BSSID (u8 *data,u8 *bssid) {if (get_from_ds (data) ==1 ) -get_address2 (data, bssid); +/* +* Extract the MAC Address in 'address2' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR2 );else if (get_to_ds (data) ==1 ) -get_address1 (data, bssid); +/* +* Extract the MAC Address in 'address1' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR1 );else -get_address3 (data, bssid); +/* +* Extract the MAC Address in 'address3' field of the MAC +* header and update the MAC Address in the allocated 'data' +* variable. +*/ +ether_addr_copy (data, bssid +ADDR3 ); }/* This function extracts the SSID from a beacon/probe response frame */ --2.1.0
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151022125333.GA21176%40ubuntu.
For more options, visit https://groups.google.com/d/optout.