Re: [Cocci] Changing format string usage with SmPL?

2019-12-03 Thread Markus Elfring
> > Which algorithm will become sufficient for your data processing needs > > around the usage of functions with variadic arguments because of format > > strings? > > Actually, I really didn't get why you're asking about that. I suggest to take another look at affected software aspects. >

Re: [Cocci] Changing format string usage with SmPL?

2019-12-03 Thread Markus Elfring
> OK, if you may have more than one argument to your print, > then you can find the offset using an expression list metavariable: > > @r@ > expression list[n] between; > @@ > > print(s,between,h2->name,...) > > Then you can use r.n in your python rule to figure out where is the %s to > change.

Re: [Cocci] Changing format string usage with SmPL?

2019-12-03 Thread Strace Labs
Unfortunately, it doesn't work. But, I am working on some solutions using Python. therefore, once we have something like: ... @r1@ format list fl; identifier fn; expression list e; position p; @@ fn("%@fl@", e@p) Then, I could handle the *format list* using *make_expr()* as well. But, Is

Re: [Cocci] Generation of expression lists by SmPL script rules?

2019-12-03 Thread Markus Elfring
> OK, if you may have more than one argument to your print, > then you can find the offset using an expression list metavariable: How challenging would it be to add support for the construction of such expression lists by programming interfaces (besides “make_expr”) of Coccinelle's software

Re: [Cocci] Changing format string usage with SmPL?

2019-12-03 Thread Strace Labs
After some research, I could create a Python function called fmt_replace_by_pos() to replace the %fmt by the Indice position. *1. Input test* int foo() { int id; struct mydata h1, *h2, s1, *s2; char *city = "Hello"; my_printf("test: char*=%s mydata=%s int=%d mydata*=%s (*mydata)=%s",