xserver: Branch 'master'

Keith Packard keithp at kemper.freedesktop.org
Thu Sep 11 18:26:20 PDT 2014


 test/list.c |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 8f8dcfee2085ba82107a8bf3872a0bb241493409
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Sep 4 23:18:03 2014 -0700

    Make list tests actually test lists
    
    Coverity scan detected that asserts were setting values, not checking them:
    
    CID 53252: Side effect in assertion (ASSERT_SIDE_EFFECT)
      assignment_where_comparison_intended: Assignment item->b = i * 2
      has a side effect. This code will work differently in a non-debug build.
      Did you intend to use a comparison ("==") instead?
    
    CID 53259: Side effect in assertion (ASSERT_SIDE_EFFECT)
      assignment_where_comparison_intended: Assignment item->a = i
      has a side effect. This code will work differently in a non-debug build.
      Did you intend to use a comparison ("==") instead?
    
    CID 53260: Side effect in assertion (ASSERT_SIDE_EFFECT)
      assignment_where_comparison_intended: Assignment item->a = i
      has a side effect. This code will work differently in a non-debug build.
      Did you intend to use a comparison ("==") instead?
    
    CID 53261: Side effect in assertion (ASSERT_SIDE_EFFECT)
      assignment_where_comparison_intended: Assignment item->b = i * 2
      has a side effect. This code will work differently in a non-debug build.
      Did you intend to use a comparison ("==") instead?
    
    Fixing those to be == caused test_nt_list_insert to start failing as
    part assumed append order, part assumed insert order, so it had to be
    fixed to use consistent ordering.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/test/list.c b/test/list.c
index f9f54ee..28d9609 100644
--- a/test/list.c
+++ b/test/list.c
@@ -249,15 +249,15 @@ test_nt_list_append(void)
 
     /* Test using nt_list_next */
     for (item = foo, i = 1; i <= 10; i++, item = nt_list_next(item, next)) {
-        assert(item->a = i);
-        assert(item->b = i * 2);
+        assert(item->a == i);
+        assert(item->b == i * 2);
     }
 
     /* Test using nt_list_for_each_entry */
     i = 1;
     nt_list_for_each_entry(item, foo, next) {
-        assert(item->a = i);
-        assert(item->b = i * 2);
+        assert(item->a == i);
+        assert(item->b == i * 2);
         i++;
     }
     assert(i == 11);
@@ -270,11 +270,11 @@ test_nt_list_insert(void)
     struct foo *foo = calloc(10, sizeof(struct foo));
     struct foo *item;
 
-    foo->a = 10;
-    foo->b = 20;
+    foo->a = 1;
+    foo->b = 2;
     nt_list_init(foo, next);
 
-    for (item = &foo[1], i = 9; i > 0; i--, item++) {
+    for (item = &foo[1], i = 10; i > 1; i--, item++) {
         item->a = i;
         item->b = i * 2;
         nt_list_init(item, next);
@@ -282,16 +282,16 @@ test_nt_list_insert(void)
     }
 
     /* Test using nt_list_next */
-    for (item = foo, i = 10; i > 0; i--, item = nt_list_next(item, next)) {
-        assert(item->a = i);
-        assert(item->b = i * 2);
+    for (item = foo, i = 1; i <= 10; i++, item = nt_list_next(item, next)) {
+        assert(item->a == i);
+        assert(item->b == i * 2);
     }
 
     /* Test using nt_list_for_each_entry */
     i = 1;
     nt_list_for_each_entry(item, foo, next) {
-        assert(item->a = i);
-        assert(item->b = i * 2);
+        assert(item->a == i);
+        assert(item->b == i * 2);
         i++;
     }
     assert(i == 11);


More information about the xorg-commit mailing list