compiling stops at od compare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When trying to compile on CentOS 7, gcc = 4.8.3

os/bluestore/BlueFS.cc: In member function ‘int
BlueFS::_read(BlueFS::FileReader*, BlueFS::FileReaderBuffer*, uint64_t,
size_t, ceph::bufferlist*, char*)’:
os/bluestore/BlueFS.cc:731:31: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
     int r = MIN((int)len, left);

This MIN is used to determine the amount of buffer that is still left
to be filed.
And here len and left are both size_t..., suggesting that both cannot be
negative. So either both need to be promoted/cast, or neither.

The cast (int)len suggests that len could be negative.
The part where that could happen is at line 750:

   off += r;
    len -= r;
    ret += r;

So there the loop exit needs len to be exactly equal to r. Even if the
loop specifies while(len>0). if len gets "negative" it grows into
something rather big.

Now if len never gets negative then it also does not need to get cast to
int. If it does, then in the unsigned case it will always be larger than
left.

So bottomline is that the cast serves no purpose?
Removing it fixes compilation.

--WjW

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux