From e8161304f74a786101a708c60c39ff2a94b78764 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Tue, 13 Sep 2022 22:43:01 -0700 Subject: [PATCH] Use hashlittle2() for xattr hashing - The non-zero key code is now in hashtable.c - The hashtable_create() code already checks for OOM --- xattrs.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/xattrs.c b/xattrs.c index b9e79a1e..26e50a6f 100644 --- a/xattrs.c +++ b/xattrs.c @@ -381,20 +381,14 @@ static int64 xattr_lookup_hash(const item_list *xalp) { const rsync_xa *rxas = xalp->items; size_t i; - int64 key = hashlittle(&xalp->count, sizeof xalp->count); + int64 key = hashlittle2(&xalp->count, sizeof xalp->count); for (i = 0; i < xalp->count; i++) { - key += hashlittle(rxas[i].name, rxas[i].name_len); + key += hashlittle2(rxas[i].name, rxas[i].name_len); if (rxas[i].datum_len > MAX_FULL_DATUM) - key += hashlittle(rxas[i].datum, xattr_sum_len); + key += hashlittle2(rxas[i].datum, xattr_sum_len); else - key += hashlittle(rxas[i].datum, rxas[i].datum_len); - } - - if (key == 0) { - /* This is very unlikely, but we should never - * return 0 as hashtable_find() doesn't like it. */ - return 1; + key += hashlittle2(rxas[i].datum, rxas[i].datum_len); } return key; @@ -475,8 +469,6 @@ static int rsync_xal_store(item_list *xalp) if (rsync_xal_h == NULL) rsync_xal_h = hashtable_create(512, HT_KEY64); - if (rsync_xal_h == NULL) - out_of_memory("rsync_xal_h hashtable_create()"); new_ref = new0(rsync_xa_list_ref); new_ref->ndx = ndx; -- 2.47.2