[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/5] Use proper comparisons while traversing the history list.
From: |
Christopher Brannon |
Subject: |
[PATCH 4/5] Use proper comparisons while traversing the history list. |
Date: |
Mon, 7 Jun 2010 12:08:48 -0500 |
The index and the length of the list both need to be stored in an
unsigned type.
Also, the comparison i <= length - 1 should be i < length, in case
length is 0.
---
src/server/history.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/server/history.c b/src/server/history.c
index a8fc7e4..ba190e3 100644
--- a/src/server/history.c
+++ b/src/server/history.c
@@ -305,9 +305,10 @@ get_messages_by_client(int uid){
GList *list = NULL;
GList *gl;
TSpeechDMessage* msg;
- int i;
+ guint i;
+ guint history_length = g_list_length(message_history);
- for (i=0;i<=g_list_length(message_history)-1;i++){
+ for (i = 0; i < history_length; i++) {
gl = g_list_nth(message_history, i);
assert(gl!=NULL);
msg = gl->data;
--
1.7.1