rem: if ((run.length << blockShift) > length) {
add: if (uint32(run.length << blockShift) > length) {
context: Stream<Cache>::WriteAt(Transaction *transaction, off_t pos, const uint8 *buffer, size_t *_length){	size_t length = *_length;	// set/check boundaries for pos/length	if (pos < 0)		pos = 0;	else if (pos + length > Node()->data.size) {		off_t oldSize = Size();		// uncached files can't be resized (Inode::SetFileSize() also		// doesn't allow this, but this way we don't have to start a		// transaction to find out).		if (Flags() & INODE_NO_CACHE)			return B_BAD_VALUE;		// the transaction doesn't have to be started already		// ToDo: what's that INODE_NO_TRANSACTION flag good for again?		if ((Flags() & INODE_NO_TRANSACTION) == 0			&& !transaction->IsStarted())			transaction->Start(fVolume, BlockNumber());		// let's grow the data stream to the size needed		status_t status = SetFileSize(transaction, pos + length);		if (status < B_OK) {			*_length = 0;			RETURN_ERROR(status);		}		// If the position of the write was beyond the file size, we		// have to fill the gap between that position and the old file		// size with zeros.		FillGapWithZeros(oldSize, pos);	}	block_run run;	off_t offset;	if (FindBlockRun(pos, run, offset) < B_OK) {		*_length = 0;		RETURN_ERROR(B_BAD_VALUE);	}	bool logStream = (Flags() & INODE_LOGGED) == INODE_LOGGED;	if (logStream		&& !transaction->IsStarted())		transaction->Start(fVolume, BlockNumber());	uint32 bytesWritten = 0;	uint32 blockSize = fVolume->BlockSize();	uint32 blockShift = fVolume->BlockShift();	uint8 *block;	// the first block_run we write could not be aligned to the block_size boundary	// (write partial block at the beginning)	// pos % block_size == (pos - offset) % block_size, offset % block_size == 0	if (pos % blockSize != 0) {		run.start += (pos - offset) / blockSize;		run.length -= (pos - offset) / blockSize;		Cache cached(fVolume, run);		if ((block = cached.Block()) == NULL) {			*_length = 0;			RETURN_ERROR(B_BAD_VALUE);		}		bytesWritten = blockSize - (pos % blockSize);		if (length < bytesWritten)			bytesWritten = length;		memcpy(block + (pos % blockSize),buffer,bytesWritten);		cached.WriteBack(transaction);		pos += bytesWritten;				length -= bytesWritten;		if (length == 0) {			*_length = bytesWritten;			return B_OK;		}		if (FindBlockRun(pos, run, offset) < B_OK) {			*_length = bytesWritten;			RETURN_ERROR(B_BAD_VALUE);		}	}	// the first block_run is already filled in at this point	// write the following complete blocks using Volume::WriteBlocks(),	// the last partial block is written using the generic Cache class	bool partial = false;	while (length > 0) {		// offset is the offset to the current pos in the block_run		run.start += (pos - offset) >> blockShift;		run.length -= (pos - offset) >> blockShift;		if ((run.length << blockShift) > length) {			if (length < blockSize) {				Cache cached(fVolume,run);				if ((block = cached.Block()) == NULL) {					*_length = bytesWritten;					RETURN_ERROR(B_BAD_VALUE);				}				memcpy(block, buffer + bytesWritten, length);				cached.WriteBack(transaction);				bytesWritten += length;				break;			}			run.length = length >> blockShift;			partial = true;		}		if (Cache::Write(transaction, fVolume, run, buffer + bytesWritten) < B_OK) {			*_length = bytesWritten;			RETURN_ERROR(B_BAD_VALUE);		}		int32 bytes = run.length << blockShift;		length -= bytes;		bytesWritten += bytes;		if (length == 0)			break;		pos += bytes;		if (partial) {			// if the last block was written only partially, point block_run			// to the remaining part			run.start += run.length;			run.length = 1;			offset = pos;		} else if (FindBlockRun(pos, run, offset) < B_OK) {			*_length = bytesWritten;			RETURN_ERROR(B_BAD_VALUE);		}	}	*_length = bytesWritten;	return B_NO_ERROR;}