public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
From: Tobias Deiminger <tobias.deiminger@posteo.de>
To: cocci@inria.fr
Subject: Re: [cocci] Search for the concatenation of meta variable + fixed string
Date: Thu, 04 Dec 2025 08:56:17 +0000	[thread overview]
Message-ID: <b5b21fa8f7d361142b60027d84edd34c@posteo.de> (raw)
In-Reply-To: <1534c930-426e-4939-8fcb-ad4a32c3e23c@web.de>

Hi,

(copy for list, sorry for again messing up To:)

Am 04.12.2025 08:54 schrieb Markus Elfring:
>> Found a workaround using fresh identifier to add an intermediate 
>> helper construct:
> 
> Please reconsider your solution approach once more.
> 
> 
>> @device_attr_ro@
>> declarer name DEVICE_ATTR_RO;
>> typedef __DEVICE_ATTR_RO_T;
>> identifier attr_name;
>> fresh identifier show_fn_name = attr_name ## "_show";
>> @@
>>   DEVICE_ATTR_RO(attr_name);
>> + __DEVICE_ATTR_RO_T attr_name = show_fn_name;
> 
> Would you really like to modify source code here?

No. It's a temporary modification as workaround. I'm using 
--no-show-diff, and don't replace inline.

> Are you more interested in an “ordinary” source code search?

Correct, it's only about searching. But not "ordinary". If there's 
another OSS tool that could do semantic code search, can deal with C 
macros and supports "hops" like first search marro, then search 
definition of function referenced by macro please tell me. Coccinelle is 
the only tool capable enough I currently know.

>> Seems to work good enough. If there are cleaner ways, let me know.
> 
> I suggest to take another look

I took reasonable amount of looks and found no better way than this [1]. 
That's why I'm posting here and hope to receive SmPL snippets that 
demonstrate a more idiomatic less complex way.

> at algorithmic properties.

The linux tree was searched in 44 s locally, which is fine for me.

> Would you need to extract identifiers from selected macro calls?

Yes, I print functions names and positions in python scripts. The 
result, verified with samples, looks complete [2].

Tobias

[1] https://github.com/haxtibal/linux/blob/tdmg/cocci/cocci/sysfs.cocci
[2] 
https://github.com/haxtibal/linux/actions/runs/19922697880/job/57114762347#step:4:512

  reply	other threads:[~2025-12-04  8:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-03 21:47 [cocci] Search for the concatenation of meta variable + fixed string (similar fresh identifier) Tobias Deiminger
2025-12-03 22:53 ` Tobias Deiminger
2025-12-04  7:54   ` [cocci] Search for the concatenation of meta variable + fixed string Markus Elfring
2025-12-04  8:56     ` Tobias Deiminger [this message]
2025-12-04  9:30       ` Markus Elfring
2025-12-05  8:30       ` [cocci] Searching for device attributes with SmPL? Markus Elfring
2025-12-07 13:40   ` [cocci] Constraints for processing with data collections Markus Elfring
2025-12-04  7:35 ` [cocci] Search for the concatenation of meta variable + fixed string Markus Elfring
2025-12-05 10:00 ` [cocci] Analysis of device attribute usage with SmPL? Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5b21fa8f7d361142b60027d84edd34c@posteo.de \
    --to=tobias.deiminger@posteo.de \
    --cc=cocci@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox