Re: [cocci] Can we match a known macro by macro name instead of expanded function name?

Julia Lawall <[email protected]>
Newsgroups fr.inria.cocci
Message-ID <[email protected]>

On Sat, 29 Nov 2025, Tobias Deiminger wrote:

> Am 29.11.2025 14:51 schrieb Julia Lawall:
> > On Sat, 29 Nov 2025, Tobias Deiminger wrote:
> >  [...]
> > The return type for the function is required in this case:
> >
> > @r@
> > attribute a;
> > identifier fn;
> > types t;
> > @@
> >
> > * t a fn(...) { ... }
>
> @Julia
> Thanks, almost there...
>
> The rule with return type you suggested works when I put the expanded form
> directly in my.c
>
>   asmlinkage unsigned long __SYSCALL_DEFINE0 mysyscall(void) { return 0; }
>
> *and* additionally add '#define __SYSCALL_DEFINE0 MACROANNOTATION' to
> standard.h. Without MACROANNOTATION I would get semantic error.
>
> But if I put the macro form to my.c (which is my original use case)
>
>   SYSCALL_DEFINE0(mysyscall) { return 0; }
>
> and add either only this
>
>   #define SYSCALL_DEFINE0(func) \
>         asmlinkage unsigned long __SYSCALL_DEFINE0 func(void)
>
> , or additionally the MACROANNOTATION hint to standard.h, I always get parse
> errors, even with return type. Any ideas what's going on?

There is no macro expansion in the semantic patch.

julia

>
>
> @Markus
> > You might point remaining improvement possibilities out for this evolving
> > software.
>
> Thanks also for your pointers. I've started learning about Coccinelle
> yesterday evening and think I'm not in a position to make improvement
> suggestions :D What Julia suggested would suite my case, once it works.
>
> Tobias
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.