Skip to contentSkip to conversation

Determining names for function parameters with SmPL?

cocci Markus Elfring 1 participant 1 message Nov 11, 2025

lore
Share & tools
lore
#0 lore raw

Hello,

I constructed the following SmPL script variant.

@initialize:python@
@@
import sys

def store_data(id, parameters, computation):
for parameter in parameters:
sys.stdout.write(f"identifier “{id}”: parameter: {repr(parameter)}\n")

@searching@
expression e;
identifier action;
parameter list pl;
type return_type != void;
@@
static inline return_type action(pl)
{
return e;
}

@script:python collection@
id << searching.action;
parameters << searching.pl;
computation << searching.e;
@@
store_data(id, parameters, computation)

Corresponding source file example:
static inline long my_test_calculation(int x, int y) {
return x + y;
}

Unfortunately, I am wondering about the following information.

Questionable test result (according to the software combination “Coccinelle 1.3.0”):
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> /usr/bin/spatch ../Probe/test-inline_function.c list_inline_non-void_functions3.cocci …
identifier “my_test_calculation”: parameter: 'int x'
identifier “my_test_calculation”: parameter: 'int y'

The function arguments are passed as strings. How should their names be determined from such data?

Will any other data structures become more appropriate for this use case?

Regards,
Markus