Re: Treat macro call like ordinary functions in smatch.
Dan Carpenter <[email protected]> Mon, 1 Jul 2024 16:10:10 +0200
| Newsgroups | org.kernel.vger.smatch |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Jun 24, 2024 at 01:50:57PM +0800, Hongyi Lu wrote:
> Hi,
>
> I have a way of extracting the macro arguments from the Smatch.
> My idea is to extend the `store_macro_pos()` in `macro_table.c` and
> delay its invocation in `pre-process.c` AFTER the arguments have been
> expanded.
> So, we can have a list of argument tokens that were passed into that macro.
>
> The changes are moderate.
> 1. Add struct macro { struct token* t; struct token_list *arg_list... };
> 2. Extend `store_macro_pos(struct token* token)` ->
> `store_macro_pos(struct token* token, struct token_list* args)`.
> 3. Delay the invocation inside `pre-process` and pass an expanded list
> of arguments when saving a macro.
> 4. Change the logic and naming in `macro_table.c`
>
> What do you think about this feature? Would it be useful in the mainline?
> Perhaps I can open a PR later.
Sorry for the delay. I travelled and then I was ill so I was offline
last week. I'm recovered now. :)
This does sound useful. I can't really review the patch without seeing
it, of course. To be honest, I'd prefer if changes were sent as a patch
to the mailing list, but I will also merge github pull requests.
In general, I will merge any features that people want. If it's useful
to you then feel free to send the patch. When it comes to kernel code
and warnings generated, then I prefer to only merge checks which find
bugs, not stuff like "propagate the error code instead returning
-EINVAL". For those kinds of minor issues or style things, then we can
merge it but turned off by default so you need to pass a command line
option to enable it. But generally, I'll try merge anything that people
find useful.
regards,
dan carpenter