From 74fd5c88eaf762152ed2dd8a54b7809fe9d2b8e4 Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Thu, 16 Jul 2015 10:01:31 -0400 Subject: SERVER-19430 Fix endian in definition of maxKey and minKey --- src/mongo/bson/bsontypes.cpp | 42 ++++-------------------------------------- src/mongo/bson/bsontypes.h | 4 ++-- 2 files changed, 6 insertions(+), 40 deletions(-) (limited to 'src/mongo/bson') diff --git a/src/mongo/bson/bsontypes.cpp b/src/mongo/bson/bsontypes.cpp index 2d12f311bef..bfea81ad58c 100644 --- a/src/mongo/bson/bsontypes.cpp +++ b/src/mongo/bson/bsontypes.cpp @@ -32,46 +32,12 @@ #include "mongo/db/jsobj.h" namespace mongo { -#pragma pack(1) -struct MaxKeyData { - MaxKeyData() { - totsize = 7; - maxkey = MaxKey; - name = 0; - eoo = EOO; - } - int totsize; - char maxkey; - char name; - char eoo; -} maxkeydata; -BSONObj maxKey((const char*)&maxkeydata); -struct MinKeyData { - MinKeyData() { - totsize = 7; - minkey = MinKey; - name = 0; - eoo = EOO; - } - int totsize; - char minkey; - char name; - char eoo; -} minkeydata; -BSONObj minKey((const char*)&minkeydata); +const char kMaxKeyData[] = {7, 0, 0, 0, static_cast(MaxKey), 0, 0}; +const BSONObj maxKey(kMaxKeyData); -/* - struct JSObj0 { - JSObj0() { - totsize = 5; - eoo = EOO; - } - int totsize; - char eoo; - } js0; -*/ -#pragma pack() +const char kMinKeyData[] = {7, 0, 0, 0, static_cast(MinKey), 0, 0}; +const BSONObj minKey(kMinKeyData); /* take a BSONType and return the name of that type as a char* */ const char* typeName(BSONType type) { diff --git a/src/mongo/bson/bsontypes.h b/src/mongo/bson/bsontypes.h index 4877dcbbbe5..9bd70822c8a 100644 --- a/src/mongo/bson/bsontypes.h +++ b/src/mongo/bson/bsontypes.h @@ -43,8 +43,8 @@ class Ordering; struct BSONArray; // empty subclass of BSONObj useful for overloading struct BSONElementCmpWithoutField; -extern BSONObj maxKey; -extern BSONObj minKey; +extern const BSONObj maxKey; +extern const BSONObj minKey; /** the complete list of valid BSON types -- cgit v1.2.1