[sword-devel] compiler warnings
Daniel Glassey
sword-devel@crosswire.org
Fri, 18 Oct 2002 20:15:04 +0100
Hi,
I'm looking into some of the compiler warnings and am curious about what is
going on in this method - error is a char so why is it being set to 7777?
gcc complains that this expression will always be false
error = (error == 7777) ? KEYERR_OUTOFBOUNDS : 0;
Regards,
Daniel
char TreeKeyIdx::getTreeNodeFromIdxOffset(long ioffset, TreeNode *node) const
{
__u32 offset;
char error = KEYERR_OUTOFBOUNDS;
if (ioffset < 0) {
ioffset = 0;
error = 7777; // out of bounds but still position to 0;
}
node->offset = ioffset;
if (idxfd > 0) {
if (idxfd->getFd() > 0) {
lseek(idxfd->getFd(), ioffset, SEEK_SET);
if (read(idxfd->getFd(), &offset, 4) == 4) {
offset = swordtoarch32(offset);
error = (error == 7777) ? KEYERR_OUTOFBOUNDS : 0;
getTreeNodeFromDatOffset(offset, node);
}
else {
lseek(idxfd->getFd(), -4, SEEK_END);
if (read(idxfd->getFd(), &offset, 4) == 4) {
offset = swordtoarch32(offset);
getTreeNodeFromDatOffset(offset, node);
}
}
}
}
return error;
}