Skip to contentSkip to conversation

Searching for function calls with known parameters (by SmPL)?

cocci Markus Elfring 2 participants 5 messages Mar 25 – Mar 26

lore
Share & tools
lore
#0 lore raw

Hello!

A function like pm_request_autosuspend() has got the property that it needs a single input parameter.
https://elixir.bootlin.com/linux/v7.0-rc5/source/include/linux/pm_runtime.h#L460-L483

Such an implementation detail can be easily determined also by the means of the semantic patch language.
I imagine that corresponding data processing would become more challenging if it should be determined that a varying number of parameters would be passed to other function calls at the beginning.
Can function calls be restricted to known parameters accordingly?

Regards,
Markus

#1 lore raw
Quoted 6 lines · Markus Elfring

Hello!

A function like pm_request_autosuspend() has got the property that it needs a single input parameter.
https://elixir.bootlin.com/linux/v7.0-rc5/source/include/linux/pm_runtime.h#L460-L483

Quoted 6 lines

Such an implementation detail can be easily determined also by the means of the semantic patch language.
I imagine that corresponding data processing would become more challenging if it should be determined that a varying number of parameters would be passed to other function calls at the beginning.
Can function calls be restricted to known parameters accordingly?

I still have no idea what you are asking about. What is the connection between a function call being placed at the beginning of a function and the number of parameters that that function call requires?

julia

#2 lore raw
Quoted 3 lines
Quoted 1 line

Can function calls be restricted to known parameters accordingly?

I still have no idea what you are asking about.

???

Quoted 2 lines

What is the connection
between a function call being placed at the beginning of a function and

It is usual that a function call can occur at the beginning of a function implementation. Such a call can occasionally be also repeated before an other call of
the referenced function.

Quoted 1 line

the number of parameters that that function call requires?

The function signature contains a parameter list.
Would you become interested to determine how many of such parameters would be passed to a selected function call?

Regards,
Markus

#3 lore raw
In reply to Julia Lawall
Quoted 3 lines

I still have no idea what you are asking about. What is the connection between a function call being placed at the beginning of a function and the number of parameters that that function call requires?

Do you see possibilities to extend an SmPL script (like the following)?

@display@
identifier call, input, name;
type t;
@@
name(t* input)
{
*call(input);
...
}

Regards,
Markus

#4 lore raw
In reply to Julia Lawall
Quoted 3 lines
Quoted 1 line

Can function calls be restricted to known parameters accordingly?

I still have no idea what you are asking about.

I hope that communication difficulties can be adjusted also with help of further (software) users.

Quoted 3 lines

What is the connection
between a function call being placed at the beginning of a function and the number of parameters that that function call requires?

I hope also that another description approach can influence evolution in more desirable directions.

Various functions were designed in the way that they handle parameters.
https://cppreference.com/w/c/language/function_definition.html

The Coccinelle software supports the metavariable type “parameter list” to some degree.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/233b5ceb1d5a701fb270ebdf0a9bd6be0a6ce53b/docs/manual/cocci_syntax.tex#L233

Such lists support “special cases” accordingly.

* They can be empty.
Would you like to exclude this case occasionally?

* More than one entry would be provided. The list length can become more interesting then.

It can occasionally be nice that parameters would explicitly be restricted to a fixed number of items by the means of the semantic patch language.

Data would be assigned to multiple parameters.
But it is not directly known by this programming interface
in which order they get passed to a function call.
The passed data can be handled by the metavariable type “expression list”. There are some development challenges remaining for the mapping of contents with the mentioned metavariable types.
Which expressions would refer to identifiers from a specified parameter list?

Regards,
Markus