kdbus: fix computing bloom filters 65/210465/1 accepted/tizen/unified/20190722.074825 submit/tizen/20190719.104741
authorAdrian Szyndela <adrian.s@samsung.com>
Fri, 19 Jul 2019 08:23:27 +0000 (10:23 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Fri, 19 Jul 2019 08:23:27 +0000 (10:23 +0200)
The bloom filters computing had been implemented in the past, basing
on systemd. However, the reimplementation introduced two bugs:
- no clearing of 'p' variable;
- clearing of hash_index variable in a wrong place.

This fixes the bugs.

The same applies to glib.

Change-Id: Ie7c602c6bc881e38c62f41d482ab3785b03c5503

dbus/kdbus-common.c

index 70ad9b0..7aff708 100755 (executable)
@@ -1311,16 +1311,16 @@ _kdbus_bloom_add_data (kdbus_t            *kdbus,
   unsigned int hash_index = 0;
 
   unsigned int c = 0;
-  uint64_t p = 0;
 
   bit_num = kdbus->bloom.size * 8;
 
   if (bit_num > 1)
     bytes_num = ((__builtin_clzll (bit_num) ^ 63U) + 7) / 8;
 
-  for (cnt_1 = 0; cnt_1 < kdbus->bloom.n_hash; cnt_1++)
+  for (cnt_1 = 0, hash_index = 0; cnt_1 < kdbus->bloom.n_hash; cnt_1++)
     {
-      for (cnt_2 = 0, hash_index = 0; cnt_2 < bytes_num; cnt_2++)
+      uint64_t p = 0;
+      for (cnt_2 = 0; cnt_2 < bytes_num; cnt_2++)
         {
           if (c <= 0)
             {