mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Improving output for single characters (with SmPL)?
@ 2026-07-22 17:03 Markus Elfring
  2026-07-23 19:26 ` Markus Elfring
  2026-07-24  9:02 ` Markus Elfring
  0 siblings, 2 replies; 8+ messages in thread
From: Markus Elfring @ 2026-07-22 17:03 UTC (permalink / raw)
  To: cocci, kernel-janitors; +Cc: LKML

Hello,

I would like to achieve further source code adjustments by the means of
the following script variant for the semantic patch language.


Example:
@initialize:python@
@@
input = ''

def convert(item):
   mark = ["'", item, "'"]
   coccinelle.text = cocci.make_expr(''.join(mark))

def common_checks(unescaped):
   if input[1] == '"':
      if input[2:] == '':
         convert(input[0] if unescaped else '\\' + input[0])
      else:
         cocci.include_match(False)
   else:
      cocci.include_match(False)

@find_update_candidate@
constant char[] input_string;
expression input_context;
position pos;
@@
 fprintf@pos(input_context, input_string);

@script:python selection@
param << find_update_candidate.input_string;
text;
@@
if param[0] == '"':
   input = param[1:]
   if input[0] == '\\':
      input = input[1:]
      if input[0] == '"':
         if input[1] == '"':
            if input[2:] == '':
               convert('"')
            else:
               cocci.include_match(False)
         else:
            cocci.include_match(False)
      else:
         common_checks(False)
   else:
      common_checks(True)
else:
   cocci.include_match(False)

@replacement@
constant char[] find_update_candidate.input_string, selection.text;
expression find_update_candidate.input_context;
position find_update_candidate.pos;
@@
(
-fprintf@pos
+putchar
 (
-stdout,
-input_string
+text
 )
|
-fprintf@pos
+fputc
 (input_context,
-input_string
+text
 )
)


Questionable test result (according to the software combination “Coccinelle 1.3.1”):
Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses/tools> time /usr/bin/spatch --timeout 23 -j4 --chunksize 1 --include-headers --no-loops -dir . …/Projekte/Coccinelle/janitor/use_fputc-20260722.cocci > …/Projekte/Bau/Linux/scripts/Coccinelle/tuning1/next/20260721/use_fputc.diff
…
HANDLING: ./tracing/rtla/src/osnoise.c
An error occurred when attempting to transform some files.

real    0m34,627s
user    1m52,330s
sys     0m4,022s

Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> lsdiff …/Projekte/Bau/Linux/scripts/Coccinelle/tuning1/next/20260721/use_fputc.diff | wc -l
49

Markus_Elfring@Sonne:…/Projekte/Linux/next2-patched/tools> LANG=C git apply …/Projekte/Bau/Linux/scripts/Coccinelle/tuning1/next/20260721/use_fputc.diff
error: patch failed: tools/bpf/bpftool/netlink_dumper.h:25
error: tools/bpf/bpftool/netlink_dumper.h: patch does not apply


Which implementation details should be reconsidered here for an affected macro?
https://elixir.bootlin.com/linux/v7.2-rc4/source/tools/bpf/bpftool/netlink_dumper.h#L25

How will chances evolve to adjust more places according to remaining update candidates?

Regards,
Markus

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-08-03  5:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-22 17:03 Improving output for single characters (with SmPL)? Markus Elfring
2026-07-23 19:26 ` Markus Elfring
2026-07-24  9:02 ` Markus Elfring
2026-08-01  8:10   ` Markus Elfring
2026-08-01  8:18     ` Julia Lawall
2026-08-01 12:00       ` [cocci] " Markus Elfring
2026-08-02 10:06       ` Markus Elfring
2026-08-03  5:40         ` [cocci] Improving parallel data processing for hierarchical structures? Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®