Semantic Patching (was Re: Current osmo-pcu patch set)

Max msuraev at sysmocom.de
Thu Sep 28 12:31:24 UTC 2017


Thank you for the links - I went over docs, related tutorials etc. It's a great tool
indeed but it's a tool for C.

OsmoPCU is written in C++ which is supported in spatch only at rudimentary level.
Moreover, the OsmoPCU code actively mixes C and C++. All-in-all I did not managed to
find a way to apply changes both to headers and the code at the same time.

For example, attached semantic patch properly updates all the invocations on
alloc_algorithm*() but not the definitions so the result is uncompilable.

So the question is, how shall I proceed with spatch?
- apply what's possible and do the rest manually?
- don't use it at all for c++?

Of course it might as well be the case that the patch is wrong or that I'm calling
spatch in a wrong way:
spatch --c++ --dir src -I src --sp-file alloc.spatch --in-place --recursive-includes

Ideas, opinions are greatly appreciated.

On 23.09.2017 06:47, Harald Welte wrote:
>
> http://cgit.osmocom.org/osmo-trx/commit/?id=e210f1a864b0752f5baeb14de8ddcfc7320007a4
>
> http://coccinelle.lip6.fr/sp.php - no sure if we want to replicate that in the
> osmocom wiki.


-- 
Max Suraev <msuraev at sysmocom.de> http://www.sysmocom.de/
======================================================================= 
* sysmocom - systems for mobile communications GmbH
* Alt-Moabit 93 
* 10559 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B 
* Geschaeftsfuehrer / Managing Director: Harald Welte 




-------------- next part --------------
// spatch --c++ --dir src -I src --sp-file alloc.spatch --in-place --recursive-includes 
@@ expression A, B, C, D, E; @@
tbf_alloc_ul_tbf(A, B, C, D, E,
(
- 1
+ true
|
- 0
+ false
)
 )
@@ expression A, B, C, D, E; @@
tbf_alloc_dl_tbf(A, B, C, D, E,
(
- 1
+ true
|
- 0
+ false
)
 )
@@
identifier alloc_algorithm_a, bts, ms, tbf, cust, single, use_trx;
@@
alloc_algorithm_a(struct gprs_rlcmac_bts *bts, GprsMs *ms, struct gprs_rlcmac_tbf *tbf,
- uint32_t cust,
uint8_t single, int use_trx)
?{ ... }
@@ expression A, B, C, D, E, G; @@
alloc_algorithm_a(A, B, C,
-D,
E, G)
@@ expression A, B, C, D, E, G; @@
alloc_algorithm_b(A, B, C,
-D,
E, G)
@@ expression A, B, C, D, E, G; @@
alloc_algorithm_dynamic(A, B, C,
-D,
E, G)
@@ expression X, A, B, C, D, E, G; @@
X->alloc_algorithm(A, B, C,
-D,
E, G)


More information about the osmocom-net-gprs mailing list