Re: jff: checksum algorithm is not as intended - Mailing list pgsql-hackers

From Tom Lane
Subject Re: jff: checksum algorithm is not as intended
Date
Msg-id 1306071.1630297304@sss.pgh.pa.us
Whole thread Raw
In response to jff: checksum algorithm is not as intended  (Yura Sokolov <y.sokolov@postgrespro.ru>)
List pgsql-hackers
Yura Sokolov <y.sokolov@postgrespro.ru> writes:
> Single round function is written as:

> #define CHECKSUM_COMP(checksum, value) do {\
>      uint32 __tmp = (checksum) ^ (value);\
>      (checksum) = __tmp * FNV_PRIME ^ (__tmp >> 17);\
> } while (0)

> And looks like it was intended to be
>      (checksum) = (__tmp * FNV_PRIME) ^ (__tmp >> 17);

I'm not following your point?  Multiplication binds tighter than XOR
in C, see e.g.

https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence

So those sure look equivalent from here.

            regards, tom lane



pgsql-hackers by date:

Previous
From: "houzj.fnst@fujitsu.com"
Date:
Subject: RE: Added schema level support for publication.
Next
From: Corey Huinker
Date:
Subject: Re: simplifying foreign key/RI checks