* Check for 0 capacity in the read(), write(), and io() hooks. In this

case the cd_driver_info::io_scheduler field is not initialized and we
  shouldn't try to access it. No idea why, but this only crashed with
  the gcc4 build.
* Fixed warning with tracing enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27762 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-09-27 21:22:22 +00:00
parent 9d53445aa2
commit bba1a2b132
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2008, Haiku, Inc. All RightsReserved.
* Copyright 2004-2008, Haiku, Inc. All rights reserved.
* Copyright 2002-2003, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
@@ -654,6 +654,9 @@ cd_read(void* cookie, off_t pos, void* buffer, size_t* _length)
cd_handle* handle = (cd_handle*)cookie;
size_t length = *_length;
if (handle->info->capacity == 0)
return B_DEV_NO_MEDIA;
IORequest request;
status_t status = request.Init(pos, buffer, length, false, 0);
if (status != B_OK)
@@ -679,6 +682,9 @@ cd_write(void* cookie, off_t pos, const void* buffer, size_t* _length)
cd_handle* handle = (cd_handle*)cookie;
size_t length = *_length;
if (handle->info->capacity == 0)
return B_DEV_NO_MEDIA;
IORequest request;
status_t status = request.Init(pos, (void*)buffer, length, true, 0);
if (status != B_OK)
@@ -703,6 +709,9 @@ cd_io(void* cookie, io_request* request)
{
cd_handle* handle = (cd_handle*)cookie;
if (handle->info->capacity == 0)
return B_DEV_NO_MEDIA;
return handle->info->io_scheduler->ScheduleRequest(request);
}
@@ -713,7 +722,7 @@ cd_ioctl(void* cookie, uint32 op, void* buffer, size_t length)
cd_handle* handle = (cd_handle*)cookie;
cd_driver_info *info = handle->info;
TRACE("ioctl(op = %d)\n", op);
TRACE("ioctl(op = %lu)\n", op);
switch (op) {
case B_GET_DEVICE_SIZE: