Re: [cocci] [1/36] coccinelle: misc: add cond_return_no_effect.cocci
Markus Elfring <[email protected]> Sun, 26 Jul 2026 14:42:31 +0200
| Newsgroups | gmane.linux.kernel.janitors,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
>> I would appreciate to clarify such an approach for a bit of dead-code e= limination >> in more detail. >=20 > I have no idea what you are talking about. What dead code are you > referring to? Variable definitions which became unused according to transformation rules by the semantic patch language. https://en.wikipedia.org/wiki/Dead-code_elimination >> I got the impression that some versions of the C programming language d= o >> not handle variable declarations also as =E2=80=9Cstatements=E2=80=9D. >> https://en.cppreference.com/c/language/statements >> >> See also: >> https://en.cppreference.com/cpp/language/statements#Declaration_stateme= nts >=20 > And the conclusion would be what? First, Coccinelle has it's own parser= . This is generally fine. > It decides what is a statement, not some wikipedia page. Does your supported data model deviate from known programming language sta= ndard specifications? Can users determine relevant differences from published software documenta= tion? > Second, Coccinelle does not consider declarations to be statements. > That's what the D is there for. You suggested to apply two metavariable types in an SmPL disjunction while trying to delete special variable definitions, didn't you? >>> The first part ensures that it is not a top-level declaration and the >>> second part does the check you had previously. >> >> I do not see so far that the intended source code restriction would be = explicitly >> expressed here. >=20 > No idea what this means. What intended code restriction are you referri= ng to? Do you try to distinguish global variable declarations from local definiti= ons anyhow? How are variable scopes be taken into account here? https://github.com/coccinelle/coccinelle/issues/322 Regards, Markus