From a1689790db10139d09c4fb29f500470564faabde Mon Sep 17 00:00:00 2001 From: Robie Basak Date: Mon, 6 May 2013 23:01:56 +0100 Subject: [PATCH] SERVER-9680 Use a signed char to store BSONType enumerations MinKey is defined as -1, so a signed char must be used to store BSONType enumerations. Using a char to store a negative value results in undefined behaviour. On i386 and amd64 architectures it happens to work because on these platforms a char is generally signed, but this is not guaranteed. This fixes a build failure on ARM, where chars are unsigned by default, and using MinKey (defined as -1) results in a compiler error. --- src/mongo/bson/bson_validate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mongo/bson/bson_validate.cpp b/src/mongo/bson/bson_validate.cpp index 9ac0bcb..88e6d48 100644 --- a/src/mongo/bson/bson_validate.cpp +++ b/src/mongo/bson/bson_validate.cpp @@ -130,8 +130,8 @@ Status validateElementInfo(Buffer* buffer, ValidationState::State* nextState) { Status status = Status::OK(); - char type; - if ( !buffer->readNumber(&type) ) + signed char type; + if ( !buffer->readNumber(&type) ) return Status( ErrorCodes::InvalidBSON, "invalid bson" ); if ( type == EOO ) { -- 1.8.1.6