diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index f09a3534628..4b5413f9e3b 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -211,6 +211,9 @@ Trunk (Unreleased) MAPREDUCE-6391. util/Timer.cc completely misunderstands _POSIX_CPUTIME (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 MAPREDUCE-5985. native-task: Fix build on macosx. Contributed by diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/Buffers.h b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/Buffers.h index 13cd545a24f..4929426d9f8 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/Buffers.h +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/Buffers.h @@ -349,31 +349,31 @@ public: return this->_capacity; } - int remain() { + uint32_t remain() { return _limit - _position; } - int limit() { + uint32_t limit() { return _limit; } - int advance(int positionOffset) { + uint32_t advance(int positionOffset) { _position += positionOffset; return _position; } - int position() { + uint32_t position() { return this->_position; } - void position(int newPos) { + void position(uint32_t newPos) { this->_position = newPos; } - void rewind(int newPos, int newLimit) { + void rewind(uint32_t newPos, uint32_t newLimit) { this->_position = newPos; - if (newLimit < 0 || newLimit > this->_capacity) { - THROW_EXCEPTION(IOException, "length smaller than zero or larger than input buffer capacity"); + if (newLimit > this->_capacity) { + THROW_EXCEPTION(IOException, "length larger than input buffer capacity"); } this->_limit = newLimit; } @@ -474,11 +474,10 @@ public: * return the length of actually filled data. */ uint32_t fill(const char * source, uint32_t maxSize) { - int remain = _size - _pos; - if (remain <= 0) { + if (_pos > _size) { return 0; } - + uint32_t remain = _size - _pos; uint32_t length = (maxSize < remain) ? maxSize : remain; simple_memcpy(_buff + _pos, source, length); _pos += length; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/MemoryBlock.cc b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/MemoryBlock.cc index b3734a170b7..cd6872a9287 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/MemoryBlock.cc +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/MemoryBlock.cc @@ -39,8 +39,8 @@ MemoryBlock::MemoryBlock(char * pos, uint32_t size) : _base(pos), _size(size), _position(0), _sorted(false) { } -KVBuffer * MemoryBlock::getKVBuffer(int index) { - if (index < 0 || index >= _kvOffsets.size()) { +KVBuffer * MemoryBlock::getKVBuffer(uint32_t index) { + if (index >= _kvOffsets.size()) { return NULL; } uint32_t offset = _kvOffsets.at(index); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/MemoryBlock.h b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/MemoryBlock.h index f85c3b61f1f..29f451839a9 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/MemoryBlock.h +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/lib/MemoryBlock.h @@ -97,7 +97,7 @@ public: return _kvOffsets.size(); } - KVBuffer * getKVBuffer(int index); + KVBuffer * getKVBuffer(uint32_t index); void sort(SortAlgorithm type, ComparatorPtr comparator); }; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/util/Random.cc b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/util/Random.cc index 6266b1f0492..2747cd927f4 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/util/Random.cc +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/util/Random.cc @@ -179,7 +179,7 @@ char * Words[] = {"diurnalness", "Homoiousian", "spiranthic", "tetragynian", "si "lithotresis", "minniebush", "zanyism", "eucalypteol", "sterilely", "unrealize", "unpatched", "hypochondriacism", "critically", "cheesecutter", }; -static size_t WordsCount = sizeof(Words) / sizeof(char *); +static uint32_t WordsCount = sizeof(Words) / sizeof(char *); Random::Random() { setSeed(time(NULL) + clock() + RandomInitializeID++); @@ -249,7 +249,7 @@ uint64_t Random::nextLog2(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; return (uint64_t)pow(10, v); } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/util/WritableUtils.cc b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/util/WritableUtils.cc index 243668117b3..8ed8dd2f3f5 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/util/WritableUtils.cc +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/src/util/WritableUtils.cc @@ -155,7 +155,8 @@ int64_t WritableUtils::ReadVLong(InputStream * stream) { } uint32_t len = DecodeVLongSize(buff); 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"); } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/test/TestPrimitives.cc b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/test/TestPrimitives.cc index b2051c7b32b..93732732a54 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/test/TestPrimitives.cc +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/native/test/TestPrimitives.cc @@ -141,7 +141,7 @@ inline char * memchrbrf4(char * p, char ch, size_t len) { return p + i + 2; } } - for (; i < len; i++) { + for (; i < (ssize_t)len; i++) { if (p[i] == ch) { return p + i; }