Skip to contentSkip to conversation

Staging: rtl8188eu: hal: Compress return logic into one line

PATCH Superseded Mihaela Muraru 3 participants 5 messages Oct 13, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8188eu: hal: Compress return logic into one line

Simplify function returns by merging assignment and return into one command line.
Found with Coccinelle
@@
expression e, ret;
@@

-ret =
+return

        e;

-return ret;

---
 ret.out | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 ret.out
ret.out new file +22 -0
new file mode 100644
index 0000000..fd4d380
@@ -0,0 +1,22 @@
+--- /home/domino/git/kernels/staging/drivers/staging/rtl8188eu/hal/phy.c
++++ /tmp/cocci-output-5790-5d9d37-phy.c
+@@ -44,8 +44,7 @@ u32 phy_query_bb_reg(struct adapter *ada
+ 
+ 	original_value = usb_read32(adapt, regaddr);
+ 	bit_shift = cal_bit_shift(bitmask);
+-	return_value = (original_value & bitmask) >> bit_shift;
+-	return return_value;
++	return (original_value & bitmask) >> bit_shift;
+ }
+ 
+ void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data)
+@@ -123,8 +122,7 @@ u32 rtw_hal_read_rfreg(struct adapter *a
+ 
+ 	original_value = rf_serial_read(adapt, rf_path, reg_addr);
+ 	bit_shift =  cal_bit_shift(bit_mask);
+-	readback_value = (original_value & bit_mask) >> bit_shift;
+-	return readback_value;
++	return (original_value & bit_mask) >> bit_shift;
+ }
+ 
+ void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path,
Signature · 1 line
2.7.4
#1 lore raw
Quoted 24 lines · Mihaela Muraru

Simplify function returns by merging assignment and return into one command line.
Found with Coccinelle
@@
expression e, ret;
@@

(quoted diff) +1 -2
-ret =
+return
        e;
-return ret;
---
 ret.out | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 ret.out
ret.out new file +0 -0
new file mode 100644
index 0000000..fd4d380

ret.out line 10

Quoted 10 lines
ret.out new file +10 -0
@@ -0,0 +1,22 @@
+--- /home/domino/git/kernels/staging/drivers/staging/rtl8188eu/hal/phy.c
++++ /tmp/cocci-output-5790-5d9d37-phy.c
+@@ -44,8 +44,7 @@ u32 phy_query_bb_reg(struct adapter *ada
+
+ 	original_value = usb_read32(adapt, regaddr);
+ 	bit_shift = cal_bit_shift(bitmask);
+-	return_value = (original_value & bitmask) >> bit_shift;
+-	return return_value;
++	return (original_value & bitmask) >> bit_shift;
+ }

Something went quite wrong here.

julia

Quoted 22 lines
ret.out new file +12 -1
+
+ void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data)
+@@ -123,8 +122,7 @@ u32 rtw_hal_read_rfreg(struct adapter *a
+
+ 	original_value = rf_serial_read(adapt, rf_path, reg_addr);
+ 	bit_shift =  cal_bit_shift(bit_mask);
+-	readback_value = (original_value & bit_mask) >> bit_shift;
+-	return readback_value;
++	return (original_value & bit_mask) >> bit_shift;
+ }
+
+ void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path,
--

2.7.4

--
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/20161013084120.GA6373%40domino-MS-16Y1.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
In reply to Mihaela Muraru
Quoted 36 lines · Mihaela Muraru

Simplify function returns by merging assignment and return into one command line.
Found with Coccinelle
@@
expression e, ret;
@@

(quoted diff) +1 -2
-ret =
+return
        e;
-return ret;
---
 ret.out | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 ret.out
ret.out new file +12 -0
new file mode 100644
index 0000000..fd4d380
@@ -0,0 +1,22 @@
+--- /home/domino/git/kernels/staging/drivers/staging/rtl8188eu/hal/phy.c
++++ /tmp/cocci-output-5790-5d9d37-phy.c
+@@ -44,8 +44,7 @@ u32 phy_query_bb_reg(struct adapter *ada
+ 
+ 	original_value = usb_read32(adapt, regaddr);
+ 	bit_shift = cal_bit_shift(bitmask);
+-	return_value = (original_value & bitmask) >> bit_shift;
+-	return return_value;
++	return (original_value & bitmask) >> bit_shift;
+ }
+ 
+ void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data)

ret.out line 22

Quoted 10 lines
ret.out new file +10 -0
+@@ -123,8 +122,7 @@ u32 rtw_hal_read_rfreg(struct adapter *a
+ 
+ 	original_value = rf_serial_read(adapt, rf_path, reg_addr);
+ 	bit_shift =  cal_bit_shift(bit_mask);
+-	readback_value = (original_value & bit_mask) >> bit_shift;
+-	return readback_value;
++	return (original_value & bit_mask) >> bit_shift;
+ }
+ 
+ void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path,

Your patch just adds a patch to the tree, not what I think you ment to send here :)

Care to try it again?

thanks,

greg k-h

#3 lore raw
Quoted 51 lines · Greg Kroah-Hartman
Quoted 36 lines · Mihaela Muraru

Simplify function returns by merging assignment and return into one command line.
Found with Coccinelle
@@
expression e, ret;
@@

(quoted diff) +1 -2
-ret =
+return
        e;
-return ret;
---
 ret.out | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 ret.out
ret.out new file +12 -0
new file mode 100644
index 0000000..fd4d380
@@ -0,0 +1,22 @@
+--- /home/domino/git/kernels/staging/drivers/staging/rtl8188eu/hal/phy.c
++++ /tmp/cocci-output-5790-5d9d37-phy.c
+@@ -44,8 +44,7 @@ u32 phy_query_bb_reg(struct adapter *ada
+
+ 	original_value = usb_read32(adapt, regaddr);
+ 	bit_shift = cal_bit_shift(bitmask);
+-	return_value = (original_value & bitmask) >> bit_shift;
+-	return return_value;
++	return (original_value & bitmask) >> bit_shift;
+ }
+
+ void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data)

ret.out line 22

Quoted 10 lines
ret.out new file +10 -0
+@@ -123,8 +122,7 @@ u32 rtw_hal_read_rfreg(struct adapter *a
+
+ 	original_value = rf_serial_read(adapt, rf_path, reg_addr);
+ 	bit_shift =  cal_bit_shift(bit_mask);
+-	readback_value = (original_value & bit_mask) >> bit_shift;
+-	return readback_value;
++	return (original_value & bit_mask) >> bit_shift;
+ }
+
+ void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path,

Your patch just adds a patch to the tree, not what I think you ment to send here :)

Quoted 1 line

Care to try it again?

You should apply the patch generated by Coccinelle, using patch -p1 < ret.out

julia

#4 lore raw
In reply to Greg Kroah-Hartman
Quoted 51 lines · Greg Kroah-Hartman
Quoted 36 lines · Mihaela Muraru

Simplify function returns by merging assignment and return into one command line.
Found with Coccinelle
@@
expression e, ret;
@@

(quoted diff) +1 -2
-ret =
+return
        e;
-return ret;
---
 ret.out | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 ret.out
ret.out new file +12 -0
new file mode 100644
index 0000000..fd4d380
@@ -0,0 +1,22 @@
+--- /home/domino/git/kernels/staging/drivers/staging/rtl8188eu/hal/phy.c
++++ /tmp/cocci-output-5790-5d9d37-phy.c
+@@ -44,8 +44,7 @@ u32 phy_query_bb_reg(struct adapter *ada
+ 
+ 	original_value = usb_read32(adapt, regaddr);
+ 	bit_shift = cal_bit_shift(bitmask);
+-	return_value = (original_value & bitmask) >> bit_shift;
+-	return return_value;
++	return (original_value & bitmask) >> bit_shift;
+ }
+ 
+ void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data)

ret.out line 22

Quoted 10 lines
ret.out new file +10 -0
+@@ -123,8 +122,7 @@ u32 rtw_hal_read_rfreg(struct adapter *a
+ 
+ 	original_value = rf_serial_read(adapt, rf_path, reg_addr);
+ 	bit_shift =  cal_bit_shift(bit_mask);
+-	readback_value = (original_value & bit_mask) >> bit_shift;
+-	return readback_value;
++	return (original_value & bit_mask) >> bit_shift;
+ }
+ 
+ void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path,

Your patch just adds a patch to the tree, not what I think you ment to send here :)

Quoted 1 line

Care to try it again?

Thanks for reply, i will send it again :)

mihaela

Quoted 3 lines

thanks,

greg k-h