Commit 3a8bd35d authored by jvoisin's avatar jvoisin Committed by Ian Goldberg
Browse files

Refactor otrl_mem_differ()

Using a convoluted while loop that changes the len variable is not

Also, make the diff volatile so we are sure the compiler does not do
some unwanted optimization.
Acked-by: default avatarDavid Goulet <>

Slightly tweaked by Ian Goldberg <>

Fixes #22
parent 0efbd84a
......@@ -169,12 +169,11 @@ void otrl_mem_init(void)
int otrl_mem_differ(const unsigned char *buf1, const unsigned char *buf2,
size_t len)
unsigned char diff = 0;
while (len) {
diff |= ((*buf1) ^ (*buf2));
volatile unsigned char diff = 0;
size_t i;
for (i = 0; i < len; ++i) {
diff |= (buf1[i] ^ buf2[i]);
return (diff != 0);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment