[webkit-reviews] review denied: [Bug 37222] [WINCE] Port SharedBuffer : [Attachment 55554] Alternative patch part 2

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon May 10 08:56:21 PDT 2010


Adam Roben (aroben) <aroben at apple.com> has denied Patrick R. Gansterer
<paroga at paroga.com>'s request for review:
Bug 37222: [WINCE] Port SharedBuffer
https://bugs.webkit.org/show_bug.cgi?id=37222

Attachment 55554: Alternative patch part 2
https://bugs.webkit.org/attachment.cgi?id=55554&action=review

------- Additional Comments from Adam Roben (aroben) <aroben at apple.com>
> +    Vector<char> buffer;
> +    DWORD bytesToRead = GetFileSize(fileHandle, 0);
> +    DWORD lastError = GetLastError();
>  
> -    // Stat the file to get its size
> -    struct _stat64 fileStat;
> -    if (_fstat64(_fileno(fileDescriptor), &fileStat))
> -	   goto exit;
> +    if (bytesToRead != INVALID_FILE_SIZE || lastError == NO_ERROR) {
> +	   DWORD bytesRead;
> +	   if (!ReadFile(fileHandle, buffer.data(), bytesToRead, &bytesRead, 0)
|| bytesToRead != bytesRead)

You're using buffer.data() here without setting buffer's size.

I'd suggest structuring things like this:

RefPtr<SharedBuffer> result;
DWORD bytesToRead = GetFileSize(fileHandle, 0);

if (bytesToRead != INVALID_FILE_SIZE || lastError == NO_ERROR) {
    Vector<char> buffer(bytesToRead);
    if (!ReadFile(...) || bytesToRead != bytesRead)
	LOG_ERROR(...);
    else
	result = SharedBuffer::adoptVector(buffer);
} else
    LOG_ERROR(...);

CloseHandle(fileHandle);
return result.release();


More information about the webkit-reviews mailing list