Evolution in API that has to be propagated to all code
- int some_fn(int a, int b, int c);
+ int some_fn(int a, int b);
Code refactor
- int some_fn(int a, int b, int c);
+ int some_fn(int a, int c, int b);
Using regex tools too tedious
int foo(char* arg) {
return 0;
}
int /* Hello */
foo(char*
arg) { return 0; }
Print diff to stdout
spatch --sp-file sempatch.cocci input.c
Output transformed file
spatch --sp-file sempatch.cocci -o output.c input.c
Inplace transform
spatch --sp-file sempatch.cocci --in-place input.c
diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 27bfb43f306e..ceca6751cdee 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -7157,7 +7157,7 @@ static void _linked_rx_signal_strength_display(struct adapter *padapter)
"UndecoratedSmoothedPWDB:%d\n", UndecoratedSmoothedPWDB);
}
-static u8 chk_ap_is_alive(struct adapter *padapter, struct sta_info *psta)
+static u8 chk_ap_is_alive(struct sta_info *psta)
{
u8 ret = false;
@@ -7221,7 +7221,7 @@ void linked_status_chk(struct adapter *padapter)
bool is_p2p_enable = false;
is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE);
- if (!chk_ap_is_alive(padapter, psta))
+ if (!chk_ap_is_alive(psta))
rx_chk = _FAIL;
if (pxmitpriv->last_tx_pkts == pxmitpriv->tx_pkts)
Matching and transformation rule
@@ // metavariable declaration @@ // matching and tranformation rule
Example
@r1@ expression E; @@ BIT(E) @script:python@ exp << r1.E; @@ print(exp)
Questions?