From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr
Cc: Henry Martin <bsdhenrymartin@gmail.com>
Subject: [cocci] Fixing indentation for a generated patch?
Date: Wed, 2 Apr 2025 11:55:37 +0200 [thread overview]
Message-ID: <897850f2-998c-4bce-a640-01adcee73a0b@web.de> (raw)
Hello,
I noticed during a patch review that a specific source code place contains
the opportunity for another bit of simplification.
Example:
avs_component_probe()
https://elixir.bootlin.com/linux/v6.14-rc6/source/sound/soc/intel/avs/pcm.c#L924-L929
I constructed a script variant (like the following) for the semantic patch language.
@replacement disable drop_else, neg_if@
constant char[] text1, text2;
expression action, check, target;
expression list inputs;
@@
-if (check)
- target = action(inputs, text1);
-else
- target = action(inputs, text2);
+target = action(inputs, (check) ? text1 : text2);
I find a corresponding test result (from the software combination “Coccinelle 1.3-00083-g4093aad2d”)
questionable according to known coding style requirements for Linux development.
Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time spatch …/Projekte/Coccinelle/janitor/use_ternary_operator7.cocci sound/soc/intel/avs/pcm.c
…
@@ -921,12 +921,8 @@ static int avs_component_probe(struct sn
…
+ mach->tplg_filename = devm_kasprintf(adev->dev, GFP_KERNEL,
+ (((vendor_id >> 16) & 0xFFFF) == 0x8086) ? "hda-8086-generic-tplg.bin" : "hda-generic-tplg.bin");
filename = kasprintf(GFP_KERNEL, "%s/%s", component->driver->topology_name_prefix,
mach->tplg_filename);
real 0m0,513s
user 0m0,454s
sys 0m0,057s
How can more appropriate indentation (including tab characters) be achieved
here automatically?
Regards,
Markus
reply other threads:[~2025-04-02 9:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=897850f2-998c-4bce-a640-01adcee73a0b@web.de \
--to=markus.elfring@web.de \
--cc=bsdhenrymartin@gmail.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).