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

Re: validating signed/unsigned comparisons with Coccinelle, was Re: [PATCH 0/3] A couple of CI fixes regarding the built-in add --patch

From
Jeff King <peff@peff.net>
Date
Aug 30, 2022, 21:32 UTC
Message-ID
<Yw6B6OB5gJhPVn5/@coredump.intra.peff.net>
In-Reply-To
<73spp934-1q41-1123-41no-q2337954op92@tzk.qr>
On Tue, Aug 30, 2022 at 11:12:24PM +0200, Johannes Schindelin wrote:
Show 8 quoted lines
> On Tue, 30 Aug 2022, Phillip Wood wrote:
> 
> > I wonder if they would be interested in fixing the parsing bug we found
> > with Peff's UNUSED() series.
> 
> Could you point me to the relevant mail? I am sure that I can come up with
> an MCVE that will help them pinpoint the bug and fix it as quickly as they
> did with this here bug.
It's the sub-thread starting here:
  https://lore.kernel.org/git/220825.86ilmg4mil.gmgdl@evledraar.gmail.com/

I tried to put together a minimal example, which would be something like:

  $ cat foo.c
  void old_function(int);
  void new_function(int);
  
  #if defined(__GNUC__)
  #define UNUSED(var) UNUSED_##var __attribute__((unused))
  #else
  #define UNUSED(var) UNUSED_##var
  #endif
  
  void foo(int UNUSED(bar), int x)
  {
  	old_function(x);
  }
  $ cat foo.cocci
  @@
  expression E;
  @@
  -old_function(E)
  +new_function(E)

but to my frustration, it actually works! If you add --verbose-parsing to the spatch command, you can see it complaining about some of the parsing. And it produces wrong outputs in the real-world with our actual unused.cocci file. I suspect the example semantic patch might just need to be a little more complicated.

-Peff
Previous: Junio C HamanoNext: Phillip Wood
Message 14 of 15 in “A couple of CI fixes regarding the built-in add --patch”
  1. 0/3 A couple of CI fixes regarding the built-in add --patchJohannes Schindelin via GitGitGadget, Aug 30, 2022
  2. 1/3 add -p: avoid ambiguous signed/unsigned comparisonJohannes Schindelin via GitGitGadget, Aug 30, 2022
  3. Junio C HamanoAug 30, 2022
  4. 2/3 t3701: test the built-in `add -i` regardless of NO_PERLJohannes Schindelin via GitGitGadget, Aug 30, 2022
  5. Jeff KingAug 30, 2022
  6. Johannes SchindelinAug 30, 2022
  7. Junio C HamanoAug 30, 2022
  8. 3/3 t6132(NO_PERL): do not run the scripted `add -p`Johannes Schindelin via GitGitGadget, Aug 30, 2022
  9. validating signed/unsigned comparisons with Coccinelle, was Re: [PATCH 0/3] A couple of CI fixes regarding the built-in add --patchJohannes Schindelin, Aug 30, 2022
  10. Phillip WoodAug 30, 2022
  11. Johannes SchindelinAug 30, 2022
  12. Junio C HamanoAug 30, 2022
  13. Junio C HamanoAug 30, 2022
  14. Jeff KingAug 30, 2022
  15. Phillip WoodAug 30, 2022

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.