MAPREDUCE-6412. Make hadoop-mapreduce-client Native code -Wall-clean (Alan Burlison via aw)

This commit is contained in:
Allen Wittenauer 2015-10-27 12:15:11 -07:00
parent 0e344902aa
commit ab99d953e4
7 changed files with 21 additions and 18 deletions

View File

@ -211,6 +211,9 @@ Trunk (Unreleased)
MAPREDUCE-6391. util/Timer.cc completely misunderstands _POSIX_CPUTIME MAPREDUCE-6391. util/Timer.cc completely misunderstands _POSIX_CPUTIME
(Alan Burlison via aw) (Alan Burlison via aw)
MAPREDUCE-6412. Make hadoop-mapreduce-client Native code -Wall-clean
(Alan Burlison via aw)
BREAKDOWN OF MAPREDUCE-2841 (NATIVE TASK) SUBTASKS BREAKDOWN OF MAPREDUCE-2841 (NATIVE TASK) SUBTASKS
MAPREDUCE-5985. native-task: Fix build on macosx. Contributed by MAPREDUCE-5985. native-task: Fix build on macosx. Contributed by

View File

@ -349,31 +349,31 @@ public:
return this->_capacity; return this->_capacity;
} }
int remain() { uint32_t remain() {
return _limit - _position; return _limit - _position;
} }
int limit() { uint32_t limit() {
return _limit; return _limit;
} }
int advance(int positionOffset) { uint32_t advance(int positionOffset) {
_position += positionOffset; _position += positionOffset;
return _position; return _position;
} }
int position() { uint32_t position() {
return this->_position; return this->_position;
} }
void position(int newPos) { void position(uint32_t newPos) {
this->_position = newPos; this->_position = newPos;
} }
void rewind(int newPos, int newLimit) { void rewind(uint32_t newPos, uint32_t newLimit) {
this->_position = newPos; this->_position = newPos;
if (newLimit < 0 || newLimit > this->_capacity) { if (newLimit > this->_capacity) {
THROW_EXCEPTION(IOException, "length smaller than zero or larger than input buffer capacity"); THROW_EXCEPTION(IOException, "length larger than input buffer capacity");
} }
this->_limit = newLimit; this->_limit = newLimit;
} }
@ -474,11 +474,10 @@ public:
* return the length of actually filled data. * return the length of actually filled data.
*/ */
uint32_t fill(const char * source, uint32_t maxSize) { uint32_t fill(const char * source, uint32_t maxSize) {
int remain = _size - _pos; if (_pos > _size) {
if (remain <= 0) {
return 0; return 0;
} }
uint32_t remain = _size - _pos;
uint32_t length = (maxSize < remain) ? maxSize : remain; uint32_t length = (maxSize < remain) ? maxSize : remain;
simple_memcpy(_buff + _pos, source, length); simple_memcpy(_buff + _pos, source, length);
_pos += length; _pos += length;

View File

@ -39,8 +39,8 @@ MemoryBlock::MemoryBlock(char * pos, uint32_t size)
: _base(pos), _size(size), _position(0), _sorted(false) { : _base(pos), _size(size), _position(0), _sorted(false) {
} }
KVBuffer * MemoryBlock::getKVBuffer(int index) { KVBuffer * MemoryBlock::getKVBuffer(uint32_t index) {
if (index < 0 || index >= _kvOffsets.size()) { if (index >= _kvOffsets.size()) {
return NULL; return NULL;
} }
uint32_t offset = _kvOffsets.at(index); uint32_t offset = _kvOffsets.at(index);

View File

@ -97,7 +97,7 @@ public:
return _kvOffsets.size(); return _kvOffsets.size();
} }
KVBuffer * getKVBuffer(int index); KVBuffer * getKVBuffer(uint32_t index);
void sort(SortAlgorithm type, ComparatorPtr comparator); void sort(SortAlgorithm type, ComparatorPtr comparator);
}; };

View File

@ -179,7 +179,7 @@ char * Words[] = {"diurnalness", "Homoiousian", "spiranthic", "tetragynian", "si
"lithotresis", "minniebush", "zanyism", "eucalypteol", "sterilely", "unrealize", "unpatched", "lithotresis", "minniebush", "zanyism", "eucalypteol", "sterilely", "unrealize", "unpatched",
"hypochondriacism", "critically", "cheesecutter", }; "hypochondriacism", "critically", "cheesecutter", };
static size_t WordsCount = sizeof(Words) / sizeof(char *); static uint32_t WordsCount = sizeof(Words) / sizeof(char *);
Random::Random() { Random::Random() {
setSeed(time(NULL) + clock() + RandomInitializeID++); setSeed(time(NULL) + clock() + RandomInitializeID++);
@ -249,7 +249,7 @@ uint64_t Random::nextLog2(uint64_t range) {
} }
uint64_t Random::nextLog10(uint64_t range) { uint64_t Random::nextLog10(uint64_t range) {
double range_r = log10(range); double range_r = log10((double)range);
double v = nextDouble() * range_r; double v = nextDouble() * range_r;
return (uint64_t)pow(10, v); return (uint64_t)pow(10, v);
} }

View File

@ -155,7 +155,8 @@ int64_t WritableUtils::ReadVLong(InputStream * stream) {
} }
uint32_t len = DecodeVLongSize(buff); uint32_t len = DecodeVLongSize(buff);
if (len > 1) { if (len > 1) {
if (stream->readFully(buff + 1, len - 1) != len - 1) { len--;
if (stream->readFully(buff + 1, len) != (int32_t)len) {
THROW_EXCEPTION(IOException, "ReadVLong reach EOF"); THROW_EXCEPTION(IOException, "ReadVLong reach EOF");
} }
} }

View File

@ -141,7 +141,7 @@ inline char * memchrbrf4(char * p, char ch, size_t len) {
return p + i + 2; return p + i + 2;
} }
} }
for (; i < len; i++) { for (; i < (ssize_t)len; i++) {
if (p[i] == ch) { if (p[i] == ch) {
return p + i; return p + i;
} }