]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd/sd-bus/bus-bloom.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / libsystemd / sd-bus / bus-bloom.c
index 91fab90cb0b8a2e4bda5432af88b6a1684aab32b..ebda6516e20526270e0fd464612051cea1945951 100644 (file)
@@ -1,5 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -19,9 +18,9 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include "util.h"
-#include "siphash24.h"
 #include "bus-bloom.h"
+#include "siphash24.h"
+#include "util.h"
 
 static inline void set_bit(uint64_t filter[], unsigned long b) {
         filter[b >> 6] |= 1ULL << (b & 63);
@@ -45,7 +44,7 @@ static void bloom_add_data(
                 const void *data,      /* Data to hash */
                 size_t n) {            /* Size of data to hash in bytes */
 
-        uint8_t h[8];
+        uint64_t h;
         uint64_t m;
         unsigned w, i, c = 0;
         unsigned hash_index;
@@ -72,11 +71,11 @@ static void bloom_add_data(
 
                 for (d = 0; d < w; d++) {
                         if (c <= 0) {
-                                siphash24(h, data, n, hash_keys[hash_index++].bytes);
+                                h = siphash24(data, n, hash_keys[hash_index++].bytes);
                                 c += 8;
                         }
 
-                        p = (p << 8ULL) | (uint64_t) h[8 - c];
+                        p = (p << 8ULL) | (uint64_t) ((uint8_t *)&h)[8 - c];
                         c--;
                 }