Checking data processing for the non-optional nest construct in SmPL
Hello,
I tried the software combination “Coccinelle 1.1.1-00467-g578998d7” (OCaml 5.0) out once more together with the following files.
Source file example:
// deleted
// See also:
// https://elixir.bootlin.com/linux/v6.3.1/source/sound/core/control_compat.c#L79
static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl,
struct snd_ctl_elem_info32 __user *data32)
{
struct snd_ctl_elem_info *data;
int err;
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (! data)
return -ENOMEM;
// deleted
err = snd_ctl_elem_info(ctl, data);
if (err < 0)
goto error;
// deleted
switch (data->type) {
case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
case SNDRV_CTL_ELEM_TYPE_INTEGER:
// deleted
default:
break;
}
err = 0;
error:
kfree(data);
return err;
}// deleted
Another script variant for the semantic patch language:
@display@
identifier result, work;
expression action, value;
expression list el;
statement es;
@@
int work(...)
{
... when any
int result;
<+...
if (...)
{
... when any
* action(el);
* return value;
}
else
es
...+>
*action(el);
*return result;
}
Test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch ../janitor/show_common_exception_handling3.cocci control_compat-excerpt-20230502.c …
@@ -24,7 +24,5 @@ static int snd_ctl_elem_info_compat(stru
}
err = 0; error:
- kfree(data);
- return err;
}
// deleted
I would expect that this source file should not be presented because the mentioned function implementation does not contain two required statements within if branches.
How should the shown software situation be reconsidered?
Are previous clarification attempts also relevant for such a data processing approach?
2017-08-18
Get the non-optional nest construct completely working for SmPL
https://github.com/coccinelle/coccinelle/issues/114
Regards,
Markus