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

Re: [PATCH] describe: use strbuf_add_unique_abbrev() for adding short hashes

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Jan 16, 2018, 17:11 UTC
Message-ID
<20180116171130.16568-1-szeder.dev@gmail.com>
In-Reply-To
<422ae05b-6541-38f3-7638-4bee1b766d91@web.de>
> Patch generated by Coccinelle (and contrib/coccinelle/strbuf.cocci).
Interesting.

The static analysis build job on Travis CI runs 'make coccicheck', so it should have caught this. However, I've looked at more build job results than I could count while working on some Travis CI related patches in the last few weeks, but I've never noticed Coccinelle proposing anything.

Now I see that Coccinelle's, and in turn 'make coccicheck's exit code only indicates that Coccinelle managed to finish without any errors (e.g. no wrong --options, missing files or whatnot), but it has nothing to do with whether it found something to transform or not. To find out the latter, we have to check the resulting 'contrib/coccinelle/*.cocci.patch' files or look closer at 'make coccicheck's standard output. If any of those '*.cocci.patch' files are not empty and make's output contains lines like:

  SPATCH result: contrib/coccinelle/strbuf.cocci.patch
then Coccinelle found something.

Well, OK, I think that might be an acceptable behavior for developers running 'make coccicheck' themselves, but totally unsuitable for automated Travis CI build jobs, because it doesn't draw our attention to Coccinelle's findings. And the only means to draw attention in an automated setting is to fail the buid job.

Good, I quickly whipped up a patch to fail the build job if any of the resulting '*.cocci.patch' files are not empty and also to include their content in the trace log, to see how that would work out, and...

> "make coccicheck" doesn't propose any other changes for current master.

... and found that 'make coccicheck' on Travis CI _does_ propose further changes for current master. You can find the build job's output including those proposed changes here:

  https://travis-ci.org/szeder/git/jobs/329296813#L586

The proposed changes coming from 'array.cocci' are replacing memmove() calls with MOVE_ARRAY(). After a (very) cursory look they all seem to make sense to me; at least after applying those changes Git can be built and the test suite still succeeds.

Unfortunately, most of the changes coming from 'strbuf.cocci' don't make any sense, they appear to be the mis-application of the "use strbuf_addstr() instead of strbuf_addf() to add a single string" rule:

  -             strbuf_addf(&sb_repo, "%d", counter);
  +             strbuf_addstr(&sb_repo, counter);

It seems that those rules need some refinement, but I have no idea about Coccinelle and this is not the time for me to dig deeper.

What makes all this weird is that running 'make coccicheck' on my own machine doesn't produce any of these additional proposed changes, just like at René's. Can it be related to differing Coccinelle versions? Travis CI installs 1.0.0~rc19.deb-3; I have 1.0.4.deb-2.

Gábor
Previous: Derrick StoleeNext: René Scharfe
Message 3 of 11 in “describe: use strbuf_add_unique_abbrev() for adding short hashes”
  1. describe: use strbuf_add_unique_abbrev() for adding short hashesRené Scharfe, Jan 15, 2018
  2. Derrick StoleeJan 16, 2018
  3. SZEDER GáborJan 16, 2018
  4. René ScharfeJan 18, 2018
  5. SZEDER GáborJan 18, 2018
  6. Lars SchneiderJan 18, 2018
  7. René ScharfeJan 19, 2018
  8. Use MOVE_ARRAYSZEDER Gábor, Jan 22, 2018
  9. Jeff KingJan 22, 2018
  10. Junio C HamanoJan 22, 2018
  11. Jeff KingJan 22, 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.