[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] hamt: New module.
From: |
Bruno Haible |
Subject: |
Re: [PATCH] hamt: New module. |
Date: |
Mon, 05 Apr 2021 15:02:14 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-206-generic; KDE/5.18.0; x86_64; ; ) |
Hi Marc,
> * tests/test-hamt.c: New file.
Can you please have a quick look whether these Coverity findings (from our
weekly Coverity run) are relevant?
________________________________________________________________________________________________________
*** CID 1503613: Null pointer dereferences (REVERSE_INULL)
/gllib/hamt.c: 876 in bucket_do_while()
870 size_t cnt = 0;
871 size_t elt_count = bucket->elt_count;
872 Hamt_entry *const *elts = bucket->elts;
873 for (size_t i = 0; i < elt_count; ++i)
874 {
875 *success = proc (elts[i], data);
>>> CID 1503613: Null pointer dereferences (REVERSE_INULL)
>>> Null-checking "success" suggests that it may be null, but it has
>>> already been dereferenced on all paths leading to the check.
876 if (!success)
877 return cnt;
878 ++cnt;
879 }
880 return cnt;
881 }
________________________________________________________________________________________________________
*** CID 1503612: Uninitialized variables (UNINIT)
/gllib/hamt.c: 952 in hamt_iterator()
946 Hamt_iterator iter;
947 iter.hamt = hamt_copy (hamt);
948 Hamt_entry *entry = hamt->root;
949 if (entry == NULL)
950 {
951 iter.depth = -1;
>>> CID 1503612: Uninitialized variables (UNINIT)
>>> Using uninitialized value "iter". Field "iter.path" is uninitialized.
952 return iter;
953 }
954 iter.depth = 0;
955 iter.path = 0;
956 iter.position = 0;
957 while (iter.entry[iter.depth] = entry, entry_type (entry) ==
subtrie_entry)
________________________________________________________________________________________________________
*** CID 1503618: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT)
/gltests/test-hamt.c: 155 in ()
149 ASSERT (hamt_do_while (hamt2, proc, &flag) == 4);
150 ASSERT (sum == 52);
151
152 hamt1 = hamt_remove (hamt2, &x4);
153 sum = 0;
154 ASSERT (hamt_do_while (hamt2, proc, &flag) == 4);
>>> CID 1503618: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT)
>>> use of "=" where "==" may have been intended
155 ASSERT (sum = 52);
156 sum = 0;
157 ASSERT (hamt_do_while (hamt1, proc, &flag) == 3);
158 ASSERT (sum = 48);
159
160 hamt_free (hamt1);
________________________________________________________________________________________________________
*** CID 1503615: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT)
/gltests/test-hamt.c: 158 in ()
152 hamt1 = hamt_remove (hamt2, &x4);
153 sum = 0;
154 ASSERT (hamt_do_while (hamt2, proc, &flag) == 4);
155 ASSERT (sum = 52);
156 sum = 0;
157 ASSERT (hamt_do_while (hamt1, proc, &flag) == 3);
>>> CID 1503615: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT)
>>> use of "=" where "==" may have been intended
158 ASSERT (sum = 48);
159
160 hamt_free (hamt1);
161 hamt_free (hamt2);
162 free_element (y5);
163 }
________________________________________________________________________________________________________
*** CID 1503614: (ASSERT_SIDE_EFFECT)
/gltests/test-hamt.c: 158 in test_general()
152 hamt1 = hamt_remove (hamt2, &x4);
153 sum = 0;
154 ASSERT (hamt_do_while (hamt2, proc, &flag) == 4);
155 ASSERT (sum = 52);
156 sum = 0;
157 ASSERT (hamt_do_while (hamt1, proc, &flag) == 3);
>>> CID 1503614: (ASSERT_SIDE_EFFECT)
>>> Assignment "sum = 48" has a side effect. This code will work
>>> differently in a non-debug build.
158 ASSERT (sum = 48);
159
160 hamt_free (hamt1);
161 hamt_free (hamt2);
162 free_element (y5);
163 }
/gltests/test-hamt.c: 155 in test_general()
149 ASSERT (hamt_do_while (hamt2, proc, &flag) == 4);
150 ASSERT (sum == 52);
151
152 hamt1 = hamt_remove (hamt2, &x4);
153 sum = 0;
154 ASSERT (hamt_do_while (hamt2, proc, &flag) == 4);
>>> CID 1503614: (ASSERT_SIDE_EFFECT)
>>> Assignment "sum = 52" has a side effect. This code will work
>>> differently in a non-debug build.
155 ASSERT (sum = 52);
156 sum = 0;
157 ASSERT (hamt_do_while (hamt1, proc, &flag) == 3);
158 ASSERT (sum = 48);
159
160 hamt_free (hamt1);
Re: [PATCH] hamt: New module.,
Bruno Haible <=