1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OP-152: Make the zeroing of LSB of has occur after hash is computed so that the

LSB of individual field values still influences the hash

Note: This update changes ALL object IDs.  A new GCS is required to match the
firmware.
This commit is contained in:
James Cotton 2011-06-04 09:47:09 -05:00
parent 599483d5ac
commit e02aa1b818

View File

@ -237,6 +237,7 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
* Calculate the unique object ID based on the object information.
* The ID will change if the object definition changes, this is intentional
* and is used to avoid connecting objects with incompatible configurations.
* The LSB is set to zero and is reserved for metadata
*/
void UAVObjectParser::calculateID(ObjectInfo* info)
{
@ -252,7 +253,7 @@ void UAVObjectParser::calculateID(ObjectInfo* info)
hash = updateHash(info->fields[n]->type, hash);
}
// Done
info->id = hash;
info->id = hash & 0xFFFFFFFE;
}
/**
@ -263,7 +264,7 @@ void UAVObjectParser::calculateID(ObjectInfo* info)
*/
quint32 UAVObjectParser::updateHash(quint32 value, quint32 hash)
{
return (hash ^ ((hash<<5) + (hash>>2) + value)) & 0xFFFFFFFE;
return (hash ^ ((hash<<5) + (hash>>2) + value));
}
/**