diff --git a/session.c b/session.c index 22572016..b915f69f 100644 --- a/session.c +++ b/session.c @@ -1,4 +1,4 @@ -/* $Id: session.c,v 1.85 2011-01-03 23:27:54 tcunha Exp $ */ +/* $Id: session.c,v 1.86 2011-01-21 23:52:36 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -180,12 +180,9 @@ session_next_session(struct session *s) if (RB_EMPTY(&sessions) || !session_alive(s)) return (NULL); - s2 = s; - do { - s2 = RB_NEXT(sessions, &sessions, s2); - if (s2 == NULL) - s2 = RB_MIN(sessions, &sessions); - } while (s2 != s); + s2 = RB_NEXT(sessions, &sessions, s2); + if (s2 == NULL) + s2 = RB_MIN(sessions, &sessions); if (s2 == s) return (NULL); return (s2); @@ -200,12 +197,9 @@ session_previous_session(struct session *s) if (RB_EMPTY(&sessions) || !session_alive(s)) return (NULL); - s2 = s; - do { - s2 = RB_PREV(sessions, &sessions, s2); - if (s2 == NULL) - s2 = RB_MAX(sessions, &sessions); - } while (s2 != s); + s2 = RB_PREV(sessions, &sessions, s2); + if (s2 == NULL) + s2 = RB_MAX(sessions, &sessions); if (s2 == s) return (NULL); return (s2);