Skip to content

Commit e816130

Browse files
committed
Use hashlittle2() for xattr hashing
- The non-zero key code is now in hashtable.c - The hashtable_create() code already checks for OOM
1 parent b012cde commit e816130

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

xattrs.c

+4-12
Original file line numberDiff line numberDiff line change
@@ -381,20 +381,14 @@ static int64 xattr_lookup_hash(const item_list *xalp)
381381
{
382382
const rsync_xa *rxas = xalp->items;
383383
size_t i;
384-
int64 key = hashlittle(&xalp->count, sizeof xalp->count);
384+
int64 key = hashlittle2(&xalp->count, sizeof xalp->count);
385385

386386
for (i = 0; i < xalp->count; i++) {
387-
key += hashlittle(rxas[i].name, rxas[i].name_len);
387+
key += hashlittle2(rxas[i].name, rxas[i].name_len);
388388
if (rxas[i].datum_len > MAX_FULL_DATUM)
389-
key += hashlittle(rxas[i].datum, xattr_sum_len);
389+
key += hashlittle2(rxas[i].datum, xattr_sum_len);
390390
else
391-
key += hashlittle(rxas[i].datum, rxas[i].datum_len);
392-
}
393-
394-
if (key == 0) {
395-
/* This is very unlikely, but we should never
396-
* return 0 as hashtable_find() doesn't like it. */
397-
return 1;
391+
key += hashlittle2(rxas[i].datum, rxas[i].datum_len);
398392
}
399393

400394
return key;
@@ -475,8 +469,6 @@ static int rsync_xal_store(item_list *xalp)
475469

476470
if (rsync_xal_h == NULL)
477471
rsync_xal_h = hashtable_create(512, HT_KEY64);
478-
if (rsync_xal_h == NULL)
479-
out_of_memory("rsync_xal_h hashtable_create()");
480472

481473
new_ref = new0(rsync_xa_list_ref);
482474
new_ref->ndx = ndx;

0 commit comments

Comments
 (0)