kdbus: fix computing bloom filters 66/210466/1 accepted/tizen/unified/20190722.074829 submit/tizen/20190719.104741
authorAdrian Szyndela <adrian.s@samsung.com>
Fri, 19 Jul 2019 08:27:28 +0000 (10:27 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Fri, 19 Jul 2019 08:27:28 +0000 (10:27 +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 libdbus.

Change-Id: I92d5fe7f270306c96e8a38c96d0a06d38b8e59b1

gio/gkdbus.c

index 4554025..ef47d94 100755 (executable)
@@ -1818,16 +1818,16 @@ g_kdbus_bloom_add_data (GKDBusWorker  *worker,
   guint hash_index = 0;
 
   guint c = 0;
-  guint64 p = 0;
 
   bit_num = (guint64)worker->bloom_size * 8;
 
   if (bit_num > 1)
     bytes_num = ((__builtin_clzll(bit_num) ^ 63U) + 7) / 8;
 
-  for (cnt_1 = 0; cnt_1 < (worker->bloom_n_hash); cnt_1++)
+  for (cnt_1 = 0, hash_index = 0; cnt_1 < (worker->bloom_n_hash); cnt_1++)
     {
-      for (cnt_2 = 0, hash_index = 0; cnt_2 < bytes_num; cnt_2++)
+      guint64 p = 0;
+      for (cnt_2 = 0; cnt_2 < bytes_num; cnt_2++)
         {
           if (c <= 0)
             {