diff options
author | Andrew Morrow <acm@mongodb.com> | 2015-07-16 10:01:31 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2015-07-16 12:23:19 -0400 |
commit | 74fd5c88eaf762152ed2dd8a54b7809fe9d2b8e4 (patch) | |
tree | 61bf82e7e6302a894495c820d649f1358b237e5d /src | |
parent | 370cbc1fbaa154b6fefa0da5fb1fbcdbd8972938 (diff) | |
download | mongo-74fd5c88eaf762152ed2dd8a54b7809fe9d2b8e4.tar.gz |
SERVER-19430 Fix endian in definition of maxKey and minKey
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/bson/bsontypes.cpp | 42 | ||||
-rw-r--r-- | src/mongo/bson/bsontypes.h | 4 |
2 files changed, 6 insertions, 40 deletions
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<char>(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<char>(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 |