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

Bug in unused.cocci?

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
May 11, 2023, 09:16 UTC
Message-ID
<5720a23e-6ac0-9a6d-3d05-4e0f34bc0589@gmail.com>
The CI static analysis job for my unit test framework patch[1] fails[2] with

Coccinelle suggests the following changes in 'contrib/coccinelle/ALL.cocci.patch': diff -u -p a/t/unit-tests/t-strbuf.c b/t/unit-tests/t-strbuf.c

--- a/t/unit-tests/t-strbuf.c
+++ b/t/unit-tests/t-strbuf.c
@@ -27,13 +27,9 @@ static void t_static_init(void)

  static void t_dynamic_init(void)
  {
-	struct strbuf buf;
-
-	strbuf_init(&buf, 1024);
  	check_uint(buf.len, ==, 0);
  	check_uint(buf.alloc, >=, 1024);
  	check_char(buf.buf[0], ==, '\0');
-	strbuf_release(&buf);
  }

  static void t_addch(struct strbuf *buf, void *data)
error: Coccinelle suggested some changes

I think this is due to a bug in unused.cocci. I'm not sure what is going 
wrong and admittedly we're unlikely to see code where an strbuf is 
initialized and then used it without calling any of the strbuf_* 
functions within our main codebase but it would be nice if the rule 
could handle this.

Best Wishes

Phillip

[1] 
https://lore.kernel.org/git/c902a166-98ce-afba-93f2-ea6027557176@gmail.com/
[2] 
https://github.com/phillipwood/git/actions/runs/4938207776/jobs/8827751328
Next: Taylor Blau
Message 1 of 3 in “Bug in unused.cocci?”
  1. Phillip WoodMay 11, 2023
  2. Taylor BlauMay 11, 2023
  3. Phillip WoodMay 12, 2023

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.