[sword-devel] compiler warnings

Troy A. Griffitts sword-devel@crosswire.org
Fri, 18 Oct 2002 12:42:11 -0700


Quick hack to fix a bug.  error status 7777 was never meant to be 
exposed outside.  Just fix the size by changing it to 77 or some other 
unique value that won't ever be set between the set and check in that 
method.




Daniel Glassey wrote:
> 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;
> }