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

[RFC PATCH 0/5] builtin/grep.c: fix a tiny logic flaw

From
Rasmus Villemoes <rv@rasmusvillemoes.dk>
Date
Feb 12, 2019, 22:26 UTC
Message-ID
<20190212222654.7432-1-rv@rasmusvillemoes.dk>
Background: I noticed that the condition in add_work() for when the
producer could add a new item was oddly different from the other
conditions on the todo_* bookkeeping variables - namely, in the other
cases we want todo_a != todo_b, whereas in add_work the condition is
todo_a+1!=todo_b. Another hint that something is slightly off is that
the code would break down if TODO_SIZE was set to 1.

The practical effect is negligible, and fixing it seems to be a bit involved, hence probably not worth the churn - and if that's the verdict, I suggest adding a comment in add_work() for future readers and/or people who copy the producer/consumer logic to their own code.

Rasmus Villemoes (5):
  builtin/grep.c: change todo_* variables to unsigned
  builtin/grep.c: refactor loop in work_done() slightly
  builtin/grep.c: add shorthand for &todo[todo_end] in add_work()
  builtin/grep.c: add todo_item helper
  builtin/grep.c: fix fence-post error in add_work()
 builtin/grep.c | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)
-- 
2.20.1
Next: Rasmus Villemoes
Message 1 of 6 in “builtin/grep.c: fix a tiny logic flaw”
  1. 0/5 builtin/grep.c: fix a tiny logic flawRasmus Villemoes, Feb 12, 2019
  2. 1/5 builtin/grep.c: change todo_* variables to unsignedRasmus Villemoes, Feb 12, 2019
  3. 2/5 builtin/grep.c: refactor loop in work_done() slightlyRasmus Villemoes, Feb 12, 2019
  4. 4/5 builtin/grep.c: add todo_item helperRasmus Villemoes, Feb 12, 2019
  5. 5/5 builtin/grep.c: fix fence-post error in add_work()Rasmus Villemoes, Feb 12, 2019
  6. 3/5 builtin/grep.c: add shorthand for &todo[todo_end] in add_work()Rasmus Villemoes, Feb 12, 2019

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.