Skip to content

Commit

Permalink
iostream: fix -Werror=type-limits warnings (OSGeo#2799)
Browse files Browse the repository at this point in the history
unsigned int is always >= 0
  • Loading branch information
nilason authored and neteler committed Nov 7, 2023
1 parent 3213f88 commit fc9506d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions include/grass/iostream/embuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ em_buffer<T, Key>::em_buffer(const unsigned short i, const unsigned long bs,
: arity(ar), level(i), basesize(bs)
{

assert((level >= 1) && (basesize >= 0));
assert(level >= 1);

char str[100];
snprintf(str, sizeof(str),
Expand Down Expand Up @@ -564,7 +564,7 @@ template <class T, class Key>
AMI_STREAM<T> *em_buffer<T, Key>::get_stream(unsigned int i)
{

assert(i >= 0 && i < index);
assert(i < index);

#ifdef SAVE_MEMORY
MY_LOG_DEBUG_ID("em_buffer::get_stream");
Expand Down Expand Up @@ -623,7 +623,7 @@ template <class T, class Key>
void em_buffer<T, Key>::put_stream(unsigned int i)
{

assert(i >= 0 && i < index);
assert(i < index);

#ifdef SAVE_MEMORY
MY_LOG_DEBUG_ID("em_buffer::put_stream");
Expand Down
4 changes: 2 additions & 2 deletions include/grass/iostream/imbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class im_buffer {
// return i'th item in buffer
T get_item(unsigned long i) const
{
assert((i >= 0) && (i < size));
assert(i < size);
return data[i];
}

Expand Down Expand Up @@ -334,7 +334,7 @@ void im_buffer<T>::reset(unsigned long start, unsigned long n)
sorted = false;
return;
}
assert((start >= 0) && (start + n <= size));
assert(start + n <= size);
size = n;
if (n) {
memmove(data, data + start, n * sizeof(T));
Expand Down
4 changes: 2 additions & 2 deletions include/grass/iostream/replacementHeap.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ template <class T, class Compare>
void ReplacementHeap<T, Compare>::deleteRun(size_t i)
{

assert(i >= 0 && i < size && mergeHeap[i].run);
assert(i < size && mergeHeap[i].run);

RHEAP_DEBUG
{
Expand Down Expand Up @@ -321,7 +321,7 @@ void ReplacementHeap<T, Compare>::heapify(size_t i)
size_t rc = rheap_rchild(i);

Compare cmpobj;
assert(i >= 0 && i < size);
assert(i < size);
if ((lc < size) && (cmpobj.compare(mergeHeap[lc].value,
mergeHeap[min_index].value) == -1)) {
min_index = lc;
Expand Down
4 changes: 2 additions & 2 deletions include/grass/iostream/replacementHeapBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ template <class T, class Compare>
void ReplacementHeapBlock<T, Compare>::deleteRun(size_t i)
{

assert(i >= 0 && i < size && mergeHeap[i].run);
assert(i < size && mergeHeap[i].run);

RBHEAP_DEBUG
{
Expand Down Expand Up @@ -294,7 +294,7 @@ void ReplacementHeapBlock<T, Compare>::heapify(size_t i)
size_t rc = rheap_rchild(i);

Compare cmpobj;
assert(i >= 0 && i < size);
assert(i < size);
if ((lc < size) && (cmpobj.compare(mergeHeap[lc].value,
mergeHeap[min_index].value) == -1)) {
min_index = lc;
Expand Down

0 comments on commit fc9506d

Please sign in to comment.