Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
From: Philipp Reisner <philipp.reisner@linbit.com>
To: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: George Spelvin <linux@horizon.com>,
	Philipp Reisner <philipp.reisner@linbit.com>,
	drbd-dev@lists.linbit.com
Subject: [Drbd-dev] [PATCH 01/17] idr: document exit conditions on idr_for_each_entry better
Date: Wed, 27 Mar 2013 14:08:33 +0100	[thread overview]
Message-ID: <1364389729-17559-2-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1364389729-17559-1-git-send-email-philipp.reisner@linbit.com>

From: George Spelvin <linux@horizon.com>

And some manual common subexpression elimination which may help the
compiler produce smaller code.

Signed-off-by: George Spelvin <linux@horizon.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
---
 include/linux/idr.h |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/linux/idr.h b/include/linux/idr.h
index 2640c7e..6ece058 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -122,11 +122,13 @@ static inline void *idr_find(struct idr *idr, int id)
  * @idp:     idr handle
  * @entry:   the type * to use as cursor
  * @id:      id entry's key
+ *
+ * @entry and @id do not need to be initialized before the loop, and
+ * after normal terminatinon @entry is left with the value NULL.  This
+ * is convenient for a "not found" value.
  */
-#define idr_for_each_entry(idp, entry, id)				\
-	for (id = 0, entry = (typeof(entry))idr_get_next((idp), &(id)); \
-	     entry != NULL;                                             \
-	     ++id, entry = (typeof(entry))idr_get_next((idp), &(id)))
+#define idr_for_each_entry(idp, entry, id)			\
+	for (id = 0; ((entry) = idr_get_next(idp, &(id))) != NULL; ++id)
 
 /*
  * Don't use the following functions.  These exist only to suppress
-- 
1.7.9.5


  reply	other threads:[~2013-03-27 13:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-27 13:08 [Drbd-dev] [PATCH 00/17] RFC: Pile of DRBD fixes Philipp Reisner
2013-03-27 13:08 ` Philipp Reisner [this message]
2013-03-27 13:08 ` [Drbd-dev] [PATCH 02/17] drbd: reset ap_in_flight counter for new connections Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 03/17] drbd: abort start of resync early, if it raced with connection breakage Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 04/17] drbd: move invalidating the whole bitmap out of after_state ch() Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 05/17] drbd: fix effective error returned when refusing an invalidate Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 06/17] drbd: drop now useless duplicate state request from invalidate Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 07/17] drbd: fix spurious warning about bitmap being locked from detach Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 08/17] drbd: Fix disconnect to keep the peer disk state if connection breaks during operation Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 09/17] drbd: only fail empty flushes if no good data is reachable Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 10/17] drbd: fix memory leak Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 11/17] drbd: validate resync_after dependency on attach already Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 12/17] drbd: Fix build error when CONFIG_CRYPTO_HMAC is not set Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 13/17] drbd: fix drbd epoch write count for ahead/behind mode Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 14/17] drbd: add module_put() on error path in drbd_proc_open() Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 15/17] drbd: fix for deadlock when using automatic split-brain-recovery Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 16/17] drbd: use sched_setscheduler() Philipp Reisner
2013-03-27 13:08 ` [Drbd-dev] [PATCH 17/17] drbd: fix if(); found by kbuild test robot Philipp Reisner
2013-03-28 16:11 ` [Drbd-dev] [PATCH 00/17] RFC: Pile of DRBD fixes Jens Axboe

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=1364389729-17559-2-git-send-email-philipp.reisner@linbit.com \
    --to=philipp.reisner@linbit.com \
    --cc=axboe@kernel.dk \
    --cc=drbd-dev@lists.linbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox