mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-30 11:56:33 -05:00
On data error, prints the number of different bits
This commit is contained in:
parent
167d1edfec
commit
3bf691ff7d
6 changed files with 41 additions and 14 deletions
|
|
@ -512,6 +512,25 @@ const char* hash_config_name(unsigned kind)
|
|||
}
|
||||
}
|
||||
|
||||
unsigned memdiff(const unsigned char* data1, const unsigned char* data2, unsigned size)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned count;
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < size; ++i) {
|
||||
unsigned j;
|
||||
unsigned char diff = data1[i] ^ data2[i];
|
||||
for (j = 0; j < 8; ++j) {
|
||||
if ((diff & 1) != 0)
|
||||
++count;
|
||||
diff >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* lock */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue