Using push/pop in all pragma pack pair to avoid potential padding bugs

This commit is contained in:
Daniel 2022-08-03 12:42:21 +08:00
parent eeffb6d25c
commit dc74b8adfd
8 changed files with 15 additions and 15 deletions

View File

@ -34,7 +34,7 @@ enum HandshakeStatus : uint8_t
enum { WelcomeMessageProgramNameSize = 64 }; enum { WelcomeMessageProgramNameSize = 64 };
enum { WelcomeMessageHostInfoSize = 1024 }; enum { WelcomeMessageHostInfoSize = 1024 };
#pragma pack( 1 ) #pragma pack( push, 1 )
// Must increase left query space after handling! // Must increase left query space after handling!
enum ServerQuery : uint8_t enum ServerQuery : uint8_t
@ -133,7 +133,7 @@ struct BroadcastMessage
enum { BroadcastMessageSize = sizeof( BroadcastMessage ) }; enum { BroadcastMessageSize = sizeof( BroadcastMessage ) };
#pragma pack() #pragma pack( pop )
} }

View File

@ -122,7 +122,7 @@ enum class QueueType : uint8_t
NUM_TYPES NUM_TYPES
}; };
#pragma pack( 1 ) #pragma pack( push, 1 )
struct QueueThreadContext struct QueueThreadContext
{ {
@ -745,7 +745,7 @@ struct QueueItem
QueueFiberLeave fiberLeave; QueueFiberLeave fiberLeave;
}; };
}; };
#pragma pack() #pragma pack( pop )
enum { QueueItemSize = sizeof( QueueItem ) }; enum { QueueItemSize = sizeof( QueueItem ) };

View File

@ -18,7 +18,7 @@
namespace tracy namespace tracy
{ {
#pragma pack( 1 ) #pragma pack( push, 1 )
struct StringRef struct StringRef
{ {
@ -663,7 +663,7 @@ struct ChildSample
enum { ChildSampleSize = sizeof( ChildSample ) }; enum { ChildSampleSize = sizeof( ChildSample ) };
#pragma pack() #pragma pack( pop )
struct ThreadData struct ThreadData

View File

@ -7,7 +7,7 @@
namespace tracy namespace tracy
{ {
#pragma pack( 1 ) #pragma pack( push, 1 )
template<typename T, class CompareDefault = std::less<T>> template<typename T, class CompareDefault = std::less<T>>
class SortedVector class SortedVector
{ {
@ -118,7 +118,7 @@ private:
uint32_t sortedEnd; uint32_t sortedEnd;
}; };
#pragma pack() #pragma pack( pop )
enum { SortedVectorSize = sizeof( SortedVector<int> ) }; enum { SortedVectorSize = sizeof( SortedVector<int> ) };

View File

@ -16,7 +16,7 @@
namespace tracy namespace tracy
{ {
#pragma pack( 1 ) #pragma pack( push, 1 )
template<typename T> template<typename T>
class VarArray class VarArray
{ {
@ -56,7 +56,7 @@ private:
uint32_t m_hash; uint32_t m_hash;
const short_ptr<T> m_ptr; const short_ptr<T> m_ptr;
}; };
#pragma pack() #pragma pack( pop )
enum { VarArraySize = sizeof( VarArray<int> ) }; enum { VarArraySize = sizeof( VarArray<int> ) };

View File

@ -19,7 +19,7 @@
namespace tracy namespace tracy
{ {
#pragma pack( 1 ) #pragma pack( push, 1 )
template<typename T> template<typename T>
class Vector class Vector
{ {
@ -348,7 +348,7 @@ private:
template<typename T> struct VectorAdapterDirect { const T& operator()( const T& it ) const { return it; } }; template<typename T> struct VectorAdapterDirect { const T& operator()( const T& it ) const { return it; } };
template<typename T> struct VectorAdapterPointer { const T& operator()( const short_ptr<T>& it ) const { return *it; } }; template<typename T> struct VectorAdapterPointer { const T& operator()( const short_ptr<T>& it ) const { return *it; } };
#pragma pack() #pragma pack( pop )
enum { VectorSize = sizeof( Vector<int> ) }; enum { VectorSize = sizeof( Vector<int> ) };

View File

@ -158,13 +158,13 @@ public:
uint8_t inlineFrame; uint8_t inlineFrame;
}; };
#pragma pack( 1 ) #pragma pack( push, 1 )
struct GhostKey struct GhostKey
{ {
CallstackFrameId frame; CallstackFrameId frame;
uint8_t inlineFrame; uint8_t inlineFrame;
}; };
#pragma pack() #pragma pack( pop )
struct GhostKeyHasher struct GhostKeyHasher
{ {