All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <rv@rasmusvillemoes.dk>
To: git@vger.kernel.org
Cc: Rasmus Villemoes <rv@rasmusvillemoes.dk>
Subject: [RFC PATCH 0/5] builtin/grep.c: fix a tiny logic flaw
Date: Tue, 12 Feb 2019 23:26:49 +0100	[thread overview]
Message-ID: <20190212222654.7432-1-rv@rasmusvillemoes.dk> (raw)

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


             reply	other threads:[~2019-02-12 22:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 22:26 Rasmus Villemoes [this message]
2019-02-12 22:26 ` [RFC PATCH 1/5] builtin/grep.c: change todo_* variables to unsigned Rasmus Villemoes
2019-02-12 22:26 ` [RFC PATCH 2/5] builtin/grep.c: refactor loop in work_done() slightly Rasmus Villemoes
2019-02-12 22:26 ` [RFC PATCH 3/5] builtin/grep.c: add shorthand for &todo[todo_end] in add_work() Rasmus Villemoes
2019-02-12 22:26 ` [RFC PATCH 4/5] builtin/grep.c: add todo_item helper Rasmus Villemoes
2019-02-12 22:26 ` [RFC PATCH 5/5] builtin/grep.c: fix fence-post error in add_work() Rasmus Villemoes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190212222654.7432-1-rv@rasmusvillemoes.dk \
    --to=rv@rasmusvillemoes.dk \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.