public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
From: Tobias Deiminger <tobias.deiminger@posteo.de>
To: cocci@inria.fr
Subject: [cocci] Search for the concatenation of meta variable + fixed string (similar fresh identifier)
Date: Wed, 03 Dec 2025 21:47:24 +0000	[thread overview]
Message-ID: <1b8dad8151ef1409adc8cb24c728907a@posteo.de> (raw)

Hello again :)

In Linux, the DEVICE_ATTR_RO macro works like this:

static ssize_t led_status_show(struct device *dev, struct 
device_attribute *attr, char *buf) { /* ... */ }

// The macro automatically concatenates led_status + _show for struct 
initialization.
static DEVICE_ATTR_RO(led_status);


I'd like to find the position of all functions assigned by 
DEVICE_ATTR_RO. So I thought to use a 1st rule to search for the 
identifier inside DEVICE_ATTR_RO, then use a 2nd rule to search for the 
inherited meta variable, concatenated with the fixed string "_show". 
Like:

@device_attr_ro@
declarer name DEVICE_ATTR_RO;
identifier attr_name;
@@
   DEVICE_ATTR_RO(attr_name);

@device_attr_ro_show_fn@
identifier device_attr_ro.attr_name;
position p_fn;
@@
   attr_name ## "_show" @ p_fn (...) {...}     // invalid syntax, but you 
get the point


This doesn't work and I couldn't figure how to do it correctly. There's 
"fresh identifier" which looks close, but it only works for +, not for 
search context. Is such a search possible? How?

Tobias

             reply	other threads:[~2025-12-03 21:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-03 21:47 Tobias Deiminger [this message]
2025-12-03 22:53 ` [cocci] Search for the concatenation of meta variable + fixed string (similar fresh identifier) 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
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=1b8dad8151ef1409adc8cb24c728907a@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