[libgdata] tests: Silence -Wunsafe-loop-optimizations
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] tests: Silence -Wunsafe-loop-optimizations
- Date: Wed, 3 Jun 2015 15:05:02 +0000 (UTC)
commit c4f9bdedcdad0c392c1b2e854179213fa0e0c52b
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Jun 3 14:04:29 2015 +0200
tests: Silence -Wunsafe-loop-optimizations
We can end up with an infinite loop if end_num is G_MAXUINT. Let's use
‘<’ instead of ‘<=’ to avoid this.
https://bugzilla.gnome.org/show_bug.cgi?id=750335
gdata/tests/streams.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/gdata/tests/streams.c b/gdata/tests/streams.c
index 25248f0..91b35c6 100644
--- a/gdata/tests/streams.c
+++ b/gdata/tests/streams.c
@@ -126,9 +126,11 @@ get_test_string (guint start_num, guint end_num)
GString *test_string;
guint i;
+ g_return_val_if_fail (end_num < G_MAXUINT, NULL);
+
test_string = g_string_new (NULL);
- for (i = start_num; i <= end_num; i++)
+ for (i = start_num; i < end_num + 1; i++)
g_string_append_printf (test_string, "%u\n", i);
return g_string_free (test_string, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]