mirror of https://github.com/qt/qtgrpc.git
QProtobufPropertyOrdering: remove dead code for char_data alignment check
Coverity rightfully complained about dead code in the char_data method, as ... % alignof(char) will never be non zero. Fix this by removing the superfluous check. As a drive-by remove unused parameters - they can be added if needed. Coverity-Id: 479414 Pick-to: 6.9 6.8 Change-Id: Ie3f2b14cbf3e18c76deae491c099ccf7ec8b7716 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
74ed4c3437
commit
4710cacf13
|
@ -70,7 +70,8 @@ private:
|
|||
};
|
||||
|
||||
Q_GLOBAL_STATIC(ProtobufOrderingRegistry, orderingRegistry)
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -144,9 +145,14 @@ FieldFlags QProtobufPropertyOrdering::fieldFlags(int index) const
|
|||
return FieldFlags { int(uint_dataForIndex(index, data->flagsOffset)) };
|
||||
}
|
||||
|
||||
uint *QProtobufPropertyOrdering::uint_data(NonConstTag _) const
|
||||
/*!
|
||||
\internal
|
||||
Access the generated uint* metadata of message properties.
|
||||
[ Data, uint_data , char_data ] > Message_metadata
|
||||
[ . . , ^ x x x x , . . . . . ]
|
||||
*/
|
||||
uint *QProtobufPropertyOrdering::uint_data(NonConstTag /*unused*/) const
|
||||
{
|
||||
Q_UNUSED(_);
|
||||
Q_ASSERT(data);
|
||||
Q_ASSERT(data->version == 0);
|
||||
quintptr dataPtr = quintptr(data);
|
||||
|
@ -165,17 +171,19 @@ const uint *QProtobufPropertyOrdering::uint_data() const
|
|||
return uint_data(NonConstTag{});
|
||||
}
|
||||
|
||||
char *QProtobufPropertyOrdering::char_data(NonConstTag _) const
|
||||
/*!
|
||||
\internal
|
||||
Access the generated char* metadata of message properties.
|
||||
[ Data, uint_data , char_data ] > Message_metadata
|
||||
[ . . , . . . . . , ^ x x x x ]
|
||||
*/
|
||||
char *QProtobufPropertyOrdering::char_data(NonConstTag /*unused*/) const
|
||||
{
|
||||
Q_UNUSED(_);
|
||||
Q_ASSERT(data);
|
||||
const uint LastOffset = data->flagsOffset;
|
||||
uint *u_data = uint_data(NonConstTag{}) + LastOffset + data->numFields;
|
||||
quintptr uptr_data = quintptr(u_data);
|
||||
if (size_t(uptr_data) % alignof(char) != 0)
|
||||
uptr_data += alignof(char) - size_t(uptr_data) % alignof(char);
|
||||
char *c_data = reinterpret_cast<char *>(uptr_data);
|
||||
return c_data;
|
||||
uint* uintDataPtr = uint_data(NonConstTag{});
|
||||
// char_data starts after the last field flag (flagsOffset + numFields)
|
||||
uint charDataOffset = data->flagsOffset + data->numFields;
|
||||
return reinterpret_cast<char *>(uintDataPtr + charDataOffset);
|
||||
}
|
||||
|
||||
const char *QProtobufPropertyOrdering::char_data() const
|
||||
|
|
Loading…
Reference in New Issue