git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] cocci: simplify check for trivial format strings

From
René Scharfe <l.s.r@web.de>
Date
Feb 2, 2018, 18:49 UTC
Message-ID
<0df36d0a-6066-05c4-d471-f25a76ce301c@web.de>
In-Reply-To
<CAM0VKjnoux1CBq-HvzRW14hXZyviG_z_Rv-qv7d0kakh18zXcw@mail.gmail.com>
Am 02.02.2018 um 15:34 schrieb SZEDER Gábor:
Show 25 quoted lines
> On Thu, Feb 1, 2018 at 7:56 PM, René Scharfe <l.s.r@web.de> wrote:
>> 353d84c537 (coccicheck: make transformation for strbuf_addf(sb, "...")
>> more precise) added a check to avoid transforming calls with format
>> strings which contain percent signs, as that would change the result.
>> It uses embedded Python code for that.  Simplify this rule by using the
>> regular expression matching operator instead.
>>
>> Signed-off-by: Rene Scharfe <l.s.r@web.de>
>> ---
>> Inspired by the Coccinelle package in Debian experimental, which lost
>> support for Python for some reason.  Tested only with that version
>> (1.0.6.deb-3) and Debian testing's 1.0.4.deb-3+b3.
> 
> FWIW, it appears to be working fine with Coccinelle version
> 1.0.0~rc19.deb-3 running on Travis CI.
> Applied it on top of 'rs/strbuf-cocci-workaround' currently at cd9a4b6d9
> (cocci: use format keyword instead of a literal string, 2018-01-19)
> along with an other patch to show the resulting suggestions in
> '.../*.cocci.patch' files, and the results look fine:
> 
>    https://travis-ci.org/szeder/git/jobs/336573242#L1466
> 
> and are the same as without this patch:
> 
>    https://travis-ci.org/szeder/git/jobs/336257153#L1466

It's good to hear that it doesn't error out, but there is no code in master that would trigger a good or bad transformation. It should propose a patch for calls like this:

	strbuf_addf(sb, "just a string, better use strbuf_addstr");
... but leave those examples here alone:
	strbuf_addf(sb, "200%% more percent signs");
	strbuf_addf(sb, "error: %m");
René
Previous: SZEDER Gábor
Message 3 of 3 in “cocci: simplify check for trivial format strings”
  1. cocci: simplify check for trivial format stringsRené Scharfe, Feb 1, 2018
  2. SZEDER GáborFeb 2, 2018
  3. René ScharfeFeb 2, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.