[RFC] Extending usage of attribute “__free” (with SmPL)?

From: Markus Elfring
Date: Sat Feb 22 2025 - 08:45:09 EST


Hello,

Various software extensions were developed based on the programming language “C”.

* Object-oriented software development became supported with some programming languages.

* Scope-based resource management became also supported for Linux components
to some degree.
See also the commit 54da6a0924311c7cf5015533991e44fb8eb12773 ("locking:
Introduce __cleanup() based infrastructure") from 2023-06-26.
Some contributors are still struggling with corresponding collateral evolution.

But a well-known source code cross-referencer can point out that an identifier
like “__free” is used in 281 source files so far.
https://elixir.bootlin.com/linux/v6.14-rc3/A/ident/__free

See also a previous presentation of analysis results:
https://lore.kernel.org/cocci/e8bf7b33-01da-43fb-b71e-cd86a02be2e6@xxxxxx/
https://sympa.inria.fr/sympa/arc/cocci/2024-10/msg00011.html
https://lkml.org/lkml/2024/10/17/1393

Thus there can be a need to adapt advice which can be offered also by
coccicheck scripts.
Example:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/coccinelle/free/put_device.cocci?h=v6.14-rc3#n2

The attribute “__free” belongs to properties of variable definitions.
Source code search approaches can eventually be adjusted also by the means of
the semantic patch language.
Corresponding software run time characteristics might become more interesting.
How will development interests evolve accordingly?


Regards,
Markus